ArcGIS Pro 2.6 API Reference Guide
GetTaskItemInfoAsync Method (TaskProjectItem)
Example 

ArcGIS.Desktop.TaskAssistant Namespace > TaskProjectItem Class : GetTaskItemInfoAsync Method
Returns information about the task item. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public Task<TaskItemInfo> GetTaskItemInfoAsync()
Public Function GetTaskItemInfoAsync() As Task(Of TaskItemInfo)

Return Value

Exceptions
ExceptionDescription
Error opening the task file. For example the taskFile is invalid.
Error opening the task file. The task item has the incorrect version.
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
// if there isn't a project task item, return
if (taskItem == null)
  return;

string message = await QueuedTask.Run(async () =>
{
  bool isOpen = taskItem.IsOpen;
  Guid taskGuid = taskItem.TaskItemGuid;

  string msg = "";
  try
  {
    TaskItemInfo taskItemInfo = await taskItem.GetTaskItemInfoAsync();

    msg = "Name : " + taskItemInfo.Name;
    msg += "\r\n" + "Description : " + taskItemInfo.Description;
    msg += "\r\n" + "Guid : " + taskItemInfo.Guid.ToString("B");
    msg += "\r\n" + "Task Count : " + taskItemInfo.GetTasks().Count();

    // iterate the tasks in the task item
    IEnumerable<TaskInfo> taskInfos = taskItemInfo.GetTasks();
    foreach (TaskInfo taskInfo in taskInfos)
    {
      string name = taskInfo.Name;
      Guid guid = taskInfo.Guid;

      // do something 
    }
  }
  catch (OpenTaskException e)
  {
    // exception thrown if task file doesn't exist or has incorrect format
    msg = e.Message;
  }
  catch (TaskFileVersionException e)
  {
    // exception thrown if task file does not support returning task information
    msg = e.Message;
  }
  return msg;
});

ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(message, "Task Information");
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

TaskProjectItem Class
TaskProjectItem Members