Hello, I am working on an ArcGIS Pro SDK project, which includes running a geoprocessing tool. This tool runs 30+ seconds. Is there a good way to show progress which the tool is running?
I have found ArcGIS.Desktop.Framework.Threading.Tasks.ProgressDialog. https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10965.html#i-heading-example. When I use the example code in my application, I don't see the progress dialog shows up (not in debug mode).
here is the code module -
public static async Task<bool> ProcessSpatialJoin(string target_feats, string join_feats, string output_feats, string search_radius)
{
//https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10957.html
var progDlg = new ProgressDialog("Running spatial join", "Cancel", 100, true);
progDlg.Show();
var progsrc=new CancelableProgressorSource(progDlg);
System.Windows.MessageBox.Show("Progress bar show");
var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
var parameters = await QueuedTask.Run(() =>
{
var join_operation = "JOIN_ONE_TO_ONE";
var match_option = "INTERSECT";
var field_map = "";
return Geoprocessing.MakeValueArray(target_feats, join_feats, output_feats, join_operation,
"KEEP_COMMON", field_map, match_option, search_radius);
});
GPExecuteToolFlags flags = GPExecuteToolFlags.AddOutputsToMap | GPExecuteToolFlags.GPThread;
var toolResult = await Geoprocessing.ExecuteToolAsync("SpatialJoin_analysis", parameters, environments, null, null, flags);
// dialog hides itself once the execution is complete
progDlg.Hide();
System.Windows.MessageBox.Show("Progress bar hide");
if (toolResult.IsFailed == true)
{
Geoprocessing.ShowMessageBox(toolResult.Messages, "GP Messages", toolResult.IsFailed ?
GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
}
return !(toolResult.IsFailed);
}