asDeferred

Converts this task to an instance of Deferred. If task is cancelled then resulting deferred will be cancelled as well. However, the opposite is not true: if the deferred is cancelled, the Task will not be cancelled. For bi-directional cancellation, an overload that accepts CancellationTokenSource can be used.


Converts this task to an instance of Deferred with a CancellationTokenSource to control cancellation. The cancellation of this function is bi-directional:

  • If the given task is cancelled, the resulting deferred will be cancelled.

  • If the resulting deferred is cancelled, the provided cancellationTokenSource will be cancelled.

Providing a CancellationTokenSource that is unrelated to the receiving Task is not supported and leads to an unspecified behaviour.