For a Revit
plugin I have written the following code:
public Result Execute(ExternalCommandData commandData,
ref string message, ElementSet elements)
{
try
{
Global.GetInstance(commandData);
message = "Studio Launcher";
var mw = new MainWindow();
mw.ShowDialg();
}
catch (Exception)
{
TaskDialog.Show("Failure", "Please Open or Create a document");
return Result.Failed;
}
return Result.Succeeded;
}
In this plugin MainWindow
is a ui that user interacts with and some transactions are take place there.
It works charm but the form is not modeless because the plugin is in the same thread as Revit
itself. To provide a modeless window I changed the mw.ShowDialg();
to mw.Show();
. Although the plugin starts successfully and MainWindow becomes modeless and user is able to interact with plugin and Revit at the same time, when I open a transaction in MainWindow, revit crashes because Execute() method is terminated before opening that transaction.
Please help me if there exist any way to develop a multi threaded plugin for revit.