ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.TaskAssistant.Events Namespace / TaskStartedEventArgs Class / UserID Property
Example

In This Topic
    UserID Property (TaskStartedEventArgs)
    In This Topic
    Gets the ID of the user who started the task.
    Syntax
    public string UserID {get;}
    Public ReadOnly Property UserID As String
    Remarks
    If user is signed in to ArcGIS Online returns the signed in user name. If not signed in, then returns the name of the user currently logged in to the Windows OS.
    Example
    Subscribe to Task Events
    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
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also