AnsweredAssumed Answered

Strange behaviour of ProgressDialog with CancelableProgressorSource

Question asked by gkmieliauskas_cellexp on Jul 24, 2019

Hi,

I would like to use ArcGIS Pro SDK ProgressDialog with Cancel button for long process with iterations. After some iterations I see that my process results reached some suitable values and I don't want to wait until the end of process.

I press Cancel button and want to  write results to file geodatabase. I get error "Edit operation failed.". If I wait until end of process all works fine. I checked with debugger and found interesting thing that saving stops without going inside

editOperation.Callback. I make testing project with Callback without any editing and get the same results.

Have anyone run into the same situation?

To check it you can use ProgressDialog sample from ArcGIS Pro SDK samples. Inside

public static Task RunCancelableProgress(CancelableProgressorSource cps, uint howLongInSeconds) add call to my test function:

 

System.Diagnostics.Debug.WriteLine(string.Format("RunCancelableProgress: Canceled {0}",

cps.Progressor.CancellationToken.IsCancellationRequested));

TestEditOperation();   // My testing function

  

}, cps.Progressor);

 

 My function code:

 

private static void TestEditOperation()

{

try

{

string message = String.Empty;

bool bResult = false;

// Create a FileGeodatabaseConnectionPath using the path to the gdb. Note: This can be a path to a .sde file.

FileGeodatabaseConnectionPath geodatabaseConnectionPath =

new FileGeodatabaseConnectionPath(new Uri(@"C:\Temp\results.gdb"));

// Create a new Geodatabase object using the FileGeodatabaseConnectionPath.

using (Geodatabase geodatabase = new Geodatabase(geodatabaseConnectionPath))

{

using (FeatureClass featClass = geodatabase.OpenDataset<FeatureClass>("Sites"))

{

EditOperation editOperation = new EditOperation();

editOperation.Callback(context =>

{

try

{

FeatureClassDefinition fcDefinition = featClass.GetDefinition();

}

catch (GeodatabaseException exObj)

{

message = exObj.Message;

}

}, featClass);

bResult = editOperation.Execute();

if (!bResult)

{

message = editOperation.ErrorMessage;

System.Diagnostics.Debug.WriteLine(message, System.Reflection.Assembly.GetExecutingAssembly().FullName);

}

else

{

var tsk = Project.Current.SaveEditsAsync();

tsk.Wait();

if (!tsk.Result)

{

message = "Saving results failed";

System.Diagnostics.Debug.WriteLine(message, System.Reflection.Assembly.GetExecutingAssembly().FullName);

bResult = false;

}

}

if (!string.IsNullOrEmpty(message))

{

MessageBox.Show(message);

}

}

}

}

catch (Exception ex)

{

System.Diagnostics.Debug.WriteLine(ex.Message, System.Reflection.Assembly.GetExecutingAssembly().FullName);

throw;

}

}

Outcomes