CancellationToken.ThrowIfCancellationRequested Method

Definition

Genera un oggetto OperationCanceledException se è stato richiesto l'annullamento di questo token.Throws a OperationCanceledException if this token has had cancellation requested.

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

Exceptions

Per il token è stato richiesto l'annullamento.The token has had cancellation requested.

L'oggetto CancellationTokenSource associato è stato eliminato.The associated CancellationTokenSource has been disposed.

Remarks

Questo metodo fornisce la funzionalità equivalente a: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  

Applies to

See also