Hi,
You could use the code from Esri community samples:
private async Task<bool> ExecuteDeleteFieldTool(BasicFeatureLayer theLayer, string fieldName)
{
try
{
return await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
var inTable = theLayer.Name;
var table = theLayer.GetTable();
var dataStore = table.GetDatastore();
var workspaceNameDef = dataStore.GetConnectionString();
var workspaceName = workspaceNameDef.Split('=')[1];
var fullSpec = System.IO.Path.Combine(workspaceName, inTable);
System.Diagnostics.Debug.WriteLine($@"Delete {fieldName} from {fullSpec}");
var parameters = Geoprocessing.MakeValueArray(fullSpec, fieldName);
var cts = new CancellationTokenSource();
var results = Geoprocessing.ExecuteToolAsync("management.DeleteField", parameters, null, cts.Token,
(eventName, o) =>
{
System.Diagnostics.Debug.WriteLine($@"GP event: {eventName}");
if (eventName == "OnMessage")
{
System.Diagnostics.Debug.WriteLine($@"Msg: {o}");
}
});
return true;
});
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
}
Write specific messages from your python code and you get content of message in event "OnMessage".
Parse message content for specific type.
For example, for progressor message could start with prefix "Progressor:". All message text could look like this "Progressor: 1". It will mean that progressor value must be equal to 1.
arcpy.AddMessage("Progressor: 1")
P.s. There is "OnProgressMessage" and "OnProgressPos" messages too which you can use directly. Try to investigate in arcpy library.
Solved: How to get return value from python tool - Esri Community
SetProgressor—ArcGIS Pro | Documentation