CancellationToken.ThrowIfCancellationRequested 方法

定义

如果此令牌已请求取消,则引发 a OperationCanceledException

public:
 void ThrowIfCancellationRequested();
public void ThrowIfCancellationRequested();
member this.ThrowIfCancellationRequested : unit -> unit
Public Sub ThrowIfCancellationRequested ()

例外

令牌已请求取消。

注解

此方法提供的功能等效于:

C#

if (token.IsCancellationRequested)
    throw new OperationCanceledException(token);
If token.IsCancellationRequested Then
    Throw New OperationCanceledException(token)
End If

适用于

另请参阅