ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Core.Geoprocessing Namespace / GPToolExecuteEventHandler Delegate
The event name values are:
Message object. Use following type conversion - see code example below.
ExampleExample

In This Topic
    GPToolExecuteEventHandler Delegate
    In This Topic
    Syntax
    public delegate void GPToolExecuteEventHandler( 
       string eventName,
       object o
    )
    Public Delegate Sub GPToolExecuteEventHandler( _
       ByVal eventName As String, _
       ByVal o As Object _
    ) 

    Parameters

    eventName
    The event name values are:
    • "OnValidate" - triggers when internal validation is done.
    • "OnMessage"
    • "OnProgressMessage"
    • "OnProgressPos"
    • "OnBeginExecute" - triggers when execution begins.
    • "OnEndExecute" - triggers when execution is complete.
    o
    Message object. Use following type conversion - see code example below.
    • "OnValidate" - (o as IGPMessage[])
    • "OnMessage" - (o as IGPMessage)
    • "OnProgressMessage" - (string)o
    • "OnProgressPos" - (int)o
    • "OnBeginExecute" - o = null
    • "OnEndExecute" - (o as IGPResult)
    Example
    gp_events
    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 = await 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 = result;
    _cts = null;
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also