ArcGIS Pro 2.7 API Reference Guide
ExecuteToolAsync(String,IEnumerable<String>,IEnumerable<KeyValuePair<String,String>>,Nullable<CancellationToken>,GPToolExecuteEventHandler,GPExecuteToolFlags) Method
Example 

ArcGIS.Desktop.Core.Geoprocessing Namespace > Geoprocessing Class > ExecuteToolAsync Method : ExecuteToolAsync(String,IEnumerable<String>,IEnumerable<KeyValuePair<String,String>>,Nullable<CancellationToken>,GPToolExecuteEventHandler,GPExecuteToolFlags) Method
Use toolboxalias.toolname, toolname_toolboxalias pattern or full path
Array of parameter values. Use MakeValueArray to pack all parameter values first.
Array of environment settings - each setting is a key-value pair of environment name and its value). Use MakeEnvironmentArray first to pack all environments.
A CancellationToken object.
Execute event delegateGPToolExecuteEventHandler(optional)
flags = GPExecuteToolFlags.Default (AddOutputsToMap | RefreshProjectItems) GPExecuteToolFlags
Executes a geoprocessing tool.
Syntax

Parameters

toolPath
Use toolboxalias.toolname, toolname_toolboxalias pattern or full path
values
Array of parameter values. Use MakeValueArray to pack all parameter values first.
environments
Array of environment settings - each setting is a key-value pair of environment name and its value). Use MakeEnvironmentArray first to pack all environments.
cancelToken
A CancellationToken object.
callback
Execute event delegateGPToolExecuteEventHandler(optional)
flags
flags = GPExecuteToolFlags.Default (AddOutputsToMap | RefreshProjectItems) GPExecuteToolFlags

Return Value

A Task of type IGPResult. See IGPResult for more information.
Remarks
This method is used to execute a geoprocessing tool. Additionally, you can also use the optional parameters to handle geoprocessing events.
Example
System.Threading.CancellationTokenSource _cts;

string ozone_points = @"C:\data\ca_ozone.gdb\O3_Sep06_3pm";

string[] args = { ozone_points, "OZONE", "", "in_memory\\raster", "300",
                    "EMPIRICAL", "300", "5", "5000",
                    "NBRTYPE=StandardCircular RADIUS=310833.272442914 ANGLE=0 NBR_MAX=10 SECTOR_TYPE=ONE_SECTOR",
                    "PREDICTION", "0.5", "EXCEED", "", "K_BESSEL" };

string tool_path = "ga.EmpiricalBayesianKriging";

_cts = new System.Threading.CancellationTokenSource();

var result = Geoprocessing.ExecuteToolAsync(tool_path, args, null, _cts.Token,
    (event_name, o) =>  // implement delegate and handle events
    {
        switch (event_name)
        {
            case "OnValidate": // stop execute if any warnings
                if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
                    _cts.Cancel();
                break;

            case "OnProgressMessage":
                string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
                System.Windows.MessageBox.Show(msg);
                _cts.Cancel();
                break;

            case "OnProgressPos":
                string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
                System.Windows.MessageBox.Show(msg2);
                _cts.Cancel();
                break;
        }
    });

var ret = await result;
_cts = null;
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

Geoprocessing Class
Geoprocessing Members
Overload List