ArcGIS Pro 2.6 API Reference Guide
TaskEndedEvent Class
Members  Example 

ArcGIS.Desktop.TaskAssistant.Events Namespace : TaskEndedEvent Class
Occurs when execution of a task ends. This occurs when a task is cancelled or when a task is successfully completed.
Object Model
TaskEndedEvent ClassSubscriptionToken ClassSubscriptionToken Class
Syntax
Example
public void TaskEvents()
{
  TaskStartedEvent.Subscribe(OnTaskStarted);
  TaskEndedEvent.Subscribe(OnTaskCompletedOrCancelled);
}

private void OnTaskStarted(TaskStartedEventArgs args)
{
  string userName = args.UserID;    // ArcGIS Online signed in userName.  If not signed in to ArcGIS Online then returns the name of the user logged in to the Windows OS.
  string projectName = args.ProjectName;

  Guid taskItemGuid = args.TaskItemGuid;
  string taskItemName = args.TaskItemName;
  string taskItemVersion = args.TaskItemVersion;

  Guid taskGuid = args.TaskGuid;
  string taskName = args.TaskName;

  DateTime startTime = args.StartTime;
}

private void OnTaskCompletedOrCancelled(TaskEndedEventArgs args)
{
  string userName = args.UserID;    // ArcGIS Online signed in userName.  If not signed in to ArcGIS Online then returns the name of the user logged in to the Windows OS.
  string projectName = args.ProjectName;

  Guid taskItemGuid = args.TaskItemGuid;
  string taskItemName = args.TaskItemName;
  string taskItemVersion = args.TaskItemVersion;

  Guid taskGuid = args.TaskGuid;
  string taskName = args.TaskName;

  DateTime startTime = args.StartTime;
  DateTime endTime = args.EndTime;
  double duration = args.Duration;

  bool completed = args.Completed;    // completed or cancelled
}
Inheritance Hierarchy

System.Object
   ArcGIS.Core.Events.EventBase
      ArcGIS.Core.Events.CompositePresentationEvent<TPayload>
         ArcGIS.Desktop.TaskAssistant.Events.TaskEndedEvent

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

TaskEndedEvent Members
ArcGIS.Desktop.TaskAssistant.Events Namespace