ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.TaskAssistant Namespace / TaskAssistantFactory Class / CloseTaskItemAsync Method
A unique identifier used to identify the task item to be closed. This identifier is the return value from the OpenTaskFileAsync(String) or OpenTaskFileAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.
Example

In This Topic
    CloseTaskItemAsync Method
    In This Topic
    Closes and unloads a specified task item from the Tasks pane. Also removes the task item from the project.
    Syntax
    Public Function CloseTaskItemAsync( _
       ByVal taskItemGuid As Guid _
    ) As Task
    public Task CloseTaskItemAsync( 
       Guid taskItemGuid
    )

    Parameters

    taskItemGuid
    A unique identifier used to identify the task item to be closed. This identifier is the return value from the OpenTaskFileAsync(String) or OpenTaskFileAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.

    Return Value

    A Task that represents CloseTask.
    Exceptions
    ExceptionDescription
    This must be called on the UI thread.
    Example
    Close a Task Item
    {
      // find the first project task item which is open
      var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault(t => t.IsOpen == true);
      // if there isn't a project task item, return
      if (taskItem == null)
        return;
    
      if (taskItem.IsOpen)
      {
        // close it
        // NOTE : The task item will also be removed from the project
        //At 2.x -
        //TaskAssistantModule.CloseTaskAsync(taskItem.TaskItemGuid);
        TaskAssistantFactory.Instance?.CloseTaskItemAsync(taskItem.TaskItemGuid);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also