CancellationToken.ThrowIfCancellationRequested Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Throws a OperationCanceledException if this token has had cancellation requested.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Sub ThrowIfCancellationRequested
public void ThrowIfCancellationRequested()

Exceptions

Exception Condition
OperationCanceledException

The token has had cancellation requested.

ObjectDisposedException

The associated CancellationTokenSource has been disposed.

Remarks

This method provides functionality equivalent to:

C#

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

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.