Select to view content in your preferred language

Cancel geoprocessing running from Dockpane

484
3
12-21-2021 10:13 PM
mody_buchbinder
Frequent Contributor

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
3 Replies
StephenRhea_NV5
Frequent 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
nadja
by
Frequent Contributor

Does this also work with the current Dockpane version? is there somewhere a code example? (I tried it, no errors, but it didnt have any effect...)

0 Kudos
mody_buchbinder
Frequent Contributor

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