CancellationToken.ThrowIfCancellationRequested 方法

定义

如果已请求取消此标记,则引发 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  

适用于

另请参阅