CancellationToken.CanBeCanceled CancellationToken.CanBeCanceled CancellationToken.CanBeCanceled CancellationToken.CanBeCanceled Property


获取此标记是否能处于已取消状态。Gets whether this token is capable of being in the canceled state.

 property bool CanBeCanceled { bool get(); };
public bool CanBeCanceled { get; }
member this.CanBeCanceled : bool
Public ReadOnly Property CanBeCanceled As Boolean


如果此令牌能够处于已取消状态,则为 true;否则为 falsetrue if this token is capable of being in the canceled state; otherwise, false.


如果CanBeCanceled将返回false,保证,该令牌将永远不会转换为已取消状态,这表示IsCancellationRequested将永远不会返回trueIf CanBeCanceled returns false, it is guaranteed that the token will never transition into a canceled state, meaning that IsCancellationRequested will never return true. 不能取消的取消标记返回的静态CancellationToken.None属性。A cancellation token that cannot be canceled is returned by the static CancellationToken.None property.

可以选择使用此属性以确定是否可以在检查的值之前取消的取消标记IsCancellationRequested属性来确定是否已取消。You can optionally use this property to determine whether a cancellation token can be canceled before examining the value of the IsCancellationRequested property to determine whether it has been canceled.