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.

C#
public bool TrySetCanceled();

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

.NET 10 i druge verzije
Proizvod Verzije
.NET 5, 6, 7, 8, 9, 10

TrySetCanceled(CancellationToken)

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

Attempts to transition the underlying Task into the Canceled state.

C#
public bool TrySetCanceled(System.Threading.CancellationToken cancellationToken);

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

.NET 10 i druge verzije
Proizvod Verzije
.NET 5, 6, 7, 8, 9, 10