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

ArcGIS.Desktop.Core.Geoprocessing Namespace > Geoprocessing Class > ExecuteToolAsync Method : ExecuteToolAsync(String,IEnumerable<String>,IEnumerable<KeyValuePair<String,String>>,CancelableProgressor,GPExecuteToolFlags) Method
Use toolboxalias.toolname or toolname_toolboxalias pattern
Array of parameter values
Array of environment settings - each setting is a key-value pair of environment name and its value). Use MakeEnvironmentArray first to pack all environments.
CancelableProgressor
flags = GPExecuteToolFlags.Default (AddOutputsToMap | RefreshProjectItems) GPExecuteToolFlags
Locks application and executes a geoprocessing tool.
Syntax

Parameters

toolPath
Use toolboxalias.toolname or toolname_toolboxalias pattern
values
Array of parameter values
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.
progressor
CancelableProgressor
flags
flags = GPExecuteToolFlags.Default (AddOutputsToMap | RefreshProjectItems) GPExecuteToolFlags

Return Value

A task of type IGPResult, IGPResult
Remarks
This method is used to execute a geoprocessing tool. Additionally, you can also use the optional to use cancellable progressor.
Example
var progDlg = new ProgressDialog("Running Geoprocessing Tool", "Cancel", 100, true);
progDlg.Show();
            
var progSrc = new CancelableProgressorSource(progDlg);

// prepare input parameter values to CopyFeatures tool
string input_data = @"C:\data\california.gdb\ca_highways";
string out_workspace = ArcGIS.Desktop.Core.Project.Current.DefaultGeodatabasePath;
string out_data = System.IO.Path.Combine(out_workspace, "ca_highways2");

// make a value array of strings to be passed to ExecuteToolAsync
var parameters = Geoprocessing.MakeValueArray(input_data, out_data);

// execute the tool
await Geoprocessing.ExecuteToolAsync("management.CopyFeatures", parameters,
    null, new CancelableProgressorSource(progDlg).Progressor, GPExecuteToolFlags.Default);

// dialog hides itself once the execution is complete
progDlg.Hide();
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

Geoprocessing Class
Geoprocessing Members
Overload List