Let us assume you have a .Net command that runs an external process that takes a long time to complete. While you are waiting for it to complete you can output a progress indicator to the command line :
Note: Following procedure works only .NET 4.5, as I’m incorporating await and aysnc methods.
[CommandMethod("TestCommand")]
static public void TestCommand()
{
Method1();
}
static public async void Method1()
{
try
{
var doc = Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
for (int i = 0; i < 20; i++)
{
ed.WriteMessage("Processing {0}...", i);
string result = await WaitASynchronously();
ed.WriteMessage("Done.\n");
}
}
catch (System.Exception ex)
{
Application.ShowAlertDialog("Error: " + ex.Message);
}
}
static public async Task<string> WaitASynchronously()
{
await Task.Delay(500);
return "Finished";
}