Using TaskInfo to Determine Task Status
A
Task
object provides information about the status of the invoked operation through its TaskInfo
data object. An instance of TaskInfo
populates the info
property of the Task
managed object at runtime. By monitoring properties of the TaskInfo
object, a client application can take appropriate action when the Task
completes, or can handle errors if the Task
does not complete successfully.The
Task.info
property contains a TaskInfo
data object that contains information about the Task
the server returns to your client application.When a
Task
is instantiated by the server, the TaskInfo.result
property is initialized to Unset
. Upon successful completion of an operation, the result
property is populated with the return type specific to the operation. The result
might be a data object, a reference to a managed object, or any other data structure as defined by the operation.For example:
- TheClusterComputeResource.AddHost_Taskmethod returns aTaskobject whoseinfoproperty contains aTaskInfodata object.
- At the start of the operation, theresultproperty isUnset.
- Upon successful completion of the operation, theresultproperty ofTaskInfocontains the managed object reference of the newly addedHostSystem.