System.Threading.Tasks.TaskCompletionSource<TResult>.TrySetCanceled Method

Attempts to transition the underlying System.Threading.Tasks.Task`1 into the TaskStatus.Canceled state.

Syntax

public bool TrySetCanceled ()

Returns

True if the operation was successful; false if the operation was unsuccessful or the object has already been disposed.

Remarks

This operation will return false if the System.Threading.Tasks.Task`1 is already in one of the three final states: TaskStatus.RanToCompletion, TaskStatus.Faulted, or TaskStatus.Canceled.

This method also returns false if the underlying System.Threading.Tasks.Task`1 has already been disposed.

Requirements

Namespace: System.Threading.Tasks
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0