Cancel geoprocessing running from Dockpane

296
2
12-21-2021 10:13 PM
mody_buchbinder
Occasional Contributor III

I am running a GP tool that takes some time from a button on Dockpane.

If the user close the Dockpane with the X (or any cancel button) I would like the GP tool to be canceled.

I still would like to use GPThread flag (or any other way that does not block the application)

What will be the best way to do it?

 

Happy holidays 🙂 

0 Kudos
2 Replies
StephenRhea_NV5
Occasional Contributor

Using the ExecuteToolAsync overload with a CancellationToken is the way to go. If you create a CancellationTokenSource scoped to the DockPane and override the DockPane's OnHidden method, you can call Cancel on the CancellationTokenSource object if the GP tool hasn't finished.

0 Kudos
mody_buchbinder
Occasional Contributor III

Hi Stephen

I will give it a try (it will take some time). I could not find an example for GP tool but I understand the concept.

Thanks

0 Kudos