Questions:
Errors occur when using the progressDialog after it has been hidden once:
Environment:
ArcMap 10.2, 10.2.2 Basic, 10.4 standard, 10.6 Basic
Windows 7 Enterprise(64 - bit) 6.1.7601 Service Pack 1
Visual Studio 2015 C# (We had similar results when running VB 6 code with the same objects except that the error was "Encountered an improper argument.")
Sample code:
The following code should, display a progress dialog that updates a message to show the loop counter.
At 10,000, the progress dialog hides. After hiding, the next iteration causes an error on the message line (15).
If you comment out the message line, it should count up to 10,000, hide the progress dialog, and show it again at 20,000 -- however the progress dialog does not show again.
public override void OnClick()
{
try
{
IProgressDialogFactory progressDlgFact = new ProgressDialogFactoryClass();
IProgressDialog2 progressDialog = (IProgressDialog2)progressDlgFact.Create(null, 0);
IStepProgressor stepProgressor = (IStepProgressor)progressDialog;
progressDialog.Title = "Please Wait...";
progressDialog.ShowDialog();
for (int i = 1; i < 50000; i++)
{
//stepProgressor.Position = i; // when this line is called after hide dialog (instead of .message = ), no error occurs
stepProgressor.Message = "Processing " + i; // when this line is called after hide dialog, SEHException occurs
if (i == 10000)
{
progressDialog.HideDialog();
}
if (i == 20000)
{
MessageBox.Show("20K");
progressDialog.ShowDialog(); // if the stepProgressor.Message line is commented out, this line does not make the dialog reappear
}
}
MessageBox.Show("Done");
progressDialog.HideDialog();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}