CancellationToken.ThrowIfCancellationRequested 方法

定義

如果已要求取消這個語彙基元,則擲回 OperationCanceledExceptionThrows a OperationCanceledException if this token has had cancellation requested.

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

例外狀況

已要求取消這個語彙基元。The token has had cancellation requested.

相關聯的 CancellationTokenSource 已經處置。The associated CancellationTokenSource has been disposed.

備註

這個方法提供的功能相當於:This method provides functionality equivalent to:

C#C#

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

適用於

另請參閱