Select to view content in your preferred language

ProgressDialog appears inconsistently

1105
3
11-04-2022 02:22 PM
DanielRatzlaff
Occasional Contributor

I have a bit of code that executes two Geoprocessing tools.  I create a ProgressDialog to show the progress, but I'm at a loss to determine why it sometimes shows and sometimes does not show.  To be more precise, sometimes the dialog appears for a split second, then disappears.  The Geoprocessing.ExecuteToolAsync still runs in the background, but my users will need that feedback from the ProgressDialog.

Code:

 

var mergeDlg = new ProgressDialog("Merging and Clipping Raster", "Cancel", 100, false);
var progsrc=new CancelableProgressorSource(mergeDlg);

await Geoprocessing.ExecuteToolAsync(
    short_mergetool_name,
    mergeParams,
    env,
    progSrc.Progressor,
    GPExecuteToolFlags.None);

await Geoprocessing.ExecuteToolAsync(
    short_cliptool_name,
    clipParams,
    null,
    progSrc.Progressor,
    GPExecuteToolFlags.Default);

 

 

I have tried bracketing the ExecuteToolAsync calls with mergeDlg.Show() and .Hide(), but it doesn't seem to make any difference.  Sometimes it displays, sometimes it doesn't.

The only other possibly relevant info I can think of is that further up in the code, I'm creating a separate simple ProgressDialog that displays during archive extraction.  That one always displays with .Show() / .Hide().  I'm not passing that one to any Geoprocessing tools.

Oh, and I'm not running this with the debugger. 😉

0 Kudos
3 Replies
DanielRatzlaff
Occasional Contributor

I still haven't figured out what's causing the dialog to sometimes disappear immediately, so I abandoned using the ProgressDialog and instead built my own UI in my dockpane and use a CancelableProgressorSource with my own callback to update the UI.

Wolf
by Esri Regular Contributor
Esri Regular Contributor

You have to reset the progressor's value back to 0 between GP tasks.  I also updated the Message string to show what GP Task is running. This worked for me:

var mergeDlg = new ProgressDialog("Creating multiple buffers", "Cancel", 100, false);
var progsrc=new CancelableProgressorSource(mergeDlg);
progsrc.Message = "Creating inner buffer: step 1";
await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArrays.InnerBuffer, null, progsrc.Progressor);
progsrc.Value = 0;
progsrc.Message = "Creating center buffer: step 2";
await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArrays.CenterBuffer, null, progsrc.Progressor);
progsrc.Value = 0;
progsrc.Message = "Creating outer buffer: step 3";
await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArrays.OuterBuffer, null, progsrc.Progressor);

The screenshot below is taken while processing the last GP task.  As you can see the progress dialog is still displaying.

Wolf_1-1668701932986.png

 

 

0 Kudos
DanielRatzlaff
Occasional Contributor

Wolf, thanks for your insight.  The problem for me is that the dialog is appearing for a split second, then disappearing, during the very first step.  But not all the time.  When the dialog does persist, the code doesn't have any issues updating with the status of multiple tools.  I just haven't found the cause of the disappearing dialog.

0 Kudos