Redigeeri

Jagamisviis:


CancellationTokenSource.CancelAfter Method

Definition

Schedules a cancel operation on this CancellationTokenSource.

Overloads

CancelAfter(Int32)

Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds.

CancelAfter(TimeSpan)

Schedules a cancel operation on this CancellationTokenSource after the specified time span.

CancelAfter(Int32)

Source:
CancellationTokenSource.cs
Source:
CancellationTokenSource.cs
Source:
CancellationTokenSource.cs

Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds.

public:
 void CancelAfter(int millisecondsDelay);
public void CancelAfter (int millisecondsDelay);
member this.CancelAfter : int -> unit
Public Sub CancelAfter (millisecondsDelay As Integer)

Parameters

millisecondsDelay
Int32

The time span to wait before canceling this CancellationTokenSource.

Exceptions

The exception thrown when this CancellationTokenSource has been disposed.

The exception thrown when millisecondsDelay is less than -1.

Remarks

The countdown for the millisecondsDelay starts during this call. When the millisecondsDelay expires, this CancellationTokenSource is canceled, if it has not been canceled already.

Subsequent calls to CancelAfter will reset the millisecondsDelay for this CancellationTokenSource, if it has not been canceled already.

Applies to

CancelAfter(TimeSpan)

Source:
CancellationTokenSource.cs
Source:
CancellationTokenSource.cs
Source:
CancellationTokenSource.cs

Schedules a cancel operation on this CancellationTokenSource after the specified time span.

public:
 void CancelAfter(TimeSpan delay);
public void CancelAfter (TimeSpan delay);
member this.CancelAfter : TimeSpan -> unit
Public Sub CancelAfter (delay As TimeSpan)

Parameters

delay
TimeSpan

The time span to wait before canceling this CancellationTokenSource.

Exceptions

The exception thrown when this CancellationTokenSource has been disposed.

delay.TotalMilliseconds is less than -1 or greater than Int32.MaxValue (or UInt32.MaxValue - 1 on some versions of .NET). Note that this upper bound is more restrictive than TimeSpan.MaxValue.

Remarks

The countdown for the delay starts during this call. When the delay expires, this CancellationTokenSource is canceled, if it has not been canceled already.

Subsequent calls to CancelAfter will reset the delay for this CancellationTokenSource, if it has not been canceled already.

Applies to