|
| .NET Framework Class Library |
| CancellationToken..::.ThrowIfCancellationRequested Method |
| CancellationToken Structure See Also Send Feedback |
Throws a OperationCanceledException if
this token has had cancellation requested.
Namespace:
System.Threading
Assembly:
System.Threading (in System.Threading.dll)
Syntax
| Visual Basic (Declaration) |
|---|
Public Sub ThrowIfCancellationRequested |
| C# |
|---|
public void ThrowIfCancellationRequested() |
Remarks
This method provides functionality equivalent to:
Copy Code | |
|---|---|
if (token.IsCancellationRequested)
throw new OperationCanceledException(token);
| |
Exceptions
| Exception | Condition |
|---|---|
| System..::.OperationCanceledException | The token has had cancellation requested. |
| System..::.ObjectDisposedException | The associated CancellationTokenSource has been disposed. |