TaskCompletionSource.TrySetCanceled 方法

定义

重载

TrySetCanceled()

尝试将基础 Task 转换为 Canceled 状态。

TrySetCanceled(CancellationToken)

尝试将基础 Task 转换为 Canceled 状态。

TrySetCanceled()

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

尝试将基础 Task 转换为 Canceled 状态。

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

返回

如果操作成功,则为 true;否则为 false

注解

如果 Task 已处于三种最终状态之一:RanToCompletionFaultedCanceled,则此操作将返回 false

适用于

TrySetCanceled(CancellationToken)

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

尝试将基础 Task 转换为 Canceled 状态。

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

参数

cancellationToken
CancellationToken

用于取消 Task 的取消标记。

返回

如果操作成功,则为 true;否则为 false

注解

如果 Task 已处于三种最终状态之一:RanToCompletionFaultedCanceled,则此操作将返回 false

适用于