ThrowIfCancellationRequested Method
Collapse the table of content
Expand the table of content

CancellationToken.ThrowIfCancellationRequested Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Throws a OperationCanceledException if this token has had cancellation requested.

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

public void ThrowIfCancellationRequested()

ExceptionCondition
OperationCanceledException

The token has had cancellation requested.

ObjectDisposedException

The associated CancellationTokenSource has been disposed.

This method provides functionality equivalent to:

C#

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

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft