I am trying to cancel all the ArcMap geoprocessing tools executions (GPTools) using an ArcObjects Extension in C#, but it doesn't seem to work or do anything for any GPTool that I am trying to cancel. The code I am using to cancel a GPTool is this:

public void Startup(ref object initializationData)
   Geoprocessor GP = new Geoprocessor();
   GP.ToolExecuting += GP_ToolExecuting;

private void GP_ToolExecuting(object sender, ToolExecutingEventArgs e)
   IGeoprocessorResult2 result = e.GPResult as IGeoProcessorResult2;

The application does run the Cancel procedure and the 'result.IsCanceled' property does change to 'true', yet the execution of the GPTool doesn't seem to stop. The ArcMap version is 10.2.2.

Any ideas what am I doing wrong or there is another way to prevent GPTools from running?

  • You can't expect a tool to just stop when you tell it to, it's the same as hitting the cancel button on the output window while a tool is running. The tool will hit a point where it checks for the cancel signal then it will roll back and delete temporary files, how long that takes will vary. I think though you need to use the ITrackCancel on the IGeoProcessor.Execute method resources.arcgis.com/en/help/arcobjects-net/componenthelp/… to cancel the tool rather than just changing the result, which is only truly valid when the tool is finished. – Michael Stimson Apr 27 '17 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.