//Option 2 - use a CancellationTokenSource - you are responsible for implementing your own cancellation. It can //either be in the callback or via the 'CallCancel' method implemented in this class internal virtual Task <IGPResult> ExecuteToolWithCancellationTokenSource(string toolPath, string[] values) { _cts = null; _cts = new CancellationTokenSource(); return(Geoprocessing.ExecuteTool(toolPath, values, _env.ToArray(), _cts.Token, (eventName, obj) => { System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1}", eventName, obj.ToString())); })); }
//Option 1 - use a CancelableProgressor - uses can click on the cancel button when the tool is running internal virtual Task <IGPResult> ExecuteToolWithCancelableProgressor(string toolPath, string[] values, CancelableProgressorSource cps) { return(Geoprocessing.ExecuteTool(toolPath, values, _env.ToArray(), cps.Progressor)); }