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;