using System;
using System.Threading;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(TestThread.MyCommands))]
namespace TestThread
{
public class TestDisp: IDisposable
{
public TestDisp()
{
AcAp.Application.
ShowAlertDialog("TestDisp() ThreadId = " +
Thread.CurrentThread.ManagedThreadId);
}
public void Dispose()
{
AcAp.Application.ShowAlertDialog("Dispose() ThreadId = " +
Thread.CurrentThread.ManagedThreadId);
}
}
public class MyCommands
{
[CommandMethod("MyCommand", CommandFlags.Modal)]
public void MyCommand()
{
try
{
using (new TestThread.TestDisp())
{
throw new System.Exception();
}
}
catch (System.Exception)
{
AcAp.Application.ShowAlertDialog("catch ThreadId = " +
Thread.CurrentThread.ManagedThreadId);
}
}
}
}