TaskCompletionSource.TrySetCanceled Method

Definition

Overloads

TrySetCanceled()

Attempts to transition the underlying Task into the Canceled state.

TrySetCanceled(CancellationToken)

Attempts to transition the underlying Task into the Canceled state.

TrySetCanceled()

Source:
TaskCompletionSource.cs
Source:
TaskCompletionSource.cs
Source:
TaskCompletionSource.cs

Attempts to transition the underlying Task into the Canceled state.

public:
 bool TrySetCanceled();
public bool TrySetCanceled ();
member this.TrySetCanceled : unit -> bool
Public Function TrySetCanceled () As Boolean

Returns

true if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Applies to

TrySetCanceled(CancellationToken)

Source:
TaskCompletionSource.cs
Source:
TaskCompletionSource.cs
Source:
TaskCompletionSource.cs

Attempts to transition the underlying Task into the Canceled state.

public:
 bool TrySetCanceled(System::Threading::CancellationToken cancellationToken);
public bool TrySetCanceled (System.Threading.CancellationToken cancellationToken);
member this.TrySetCanceled : System.Threading.CancellationToken -> bool
Public Function TrySetCanceled (cancellationToken As CancellationToken) As Boolean

Parameters

cancellationToken
CancellationToken

The cancellation token with which to cancel the Task.

Returns

true if the operation was successful; otherwise, false.

Remarks

This operation will return false if the Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.

Applies to