Breyta

Deila með


CancellationTokenSource Constructors

Definition

Initializes the CancellationTokenSource.

Overloads

CancellationTokenSource()

Initializes a new instance of the CancellationTokenSource class.

CancellationTokenSource(Int32)

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified delay in milliseconds.

CancellationTokenSource(TimeSpan)

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified time span.

CancellationTokenSource(TimeSpan, TimeProvider)

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified TimeSpan.

CancellationTokenSource()

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

Initializes a new instance of the CancellationTokenSource class.

public:
 CancellationTokenSource();
public CancellationTokenSource ();
Public Sub New ()

See also

Applies to

CancellationTokenSource(Int32)

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

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified delay in milliseconds.

public:
 CancellationTokenSource(int millisecondsDelay);
public CancellationTokenSource (int millisecondsDelay);
new System.Threading.CancellationTokenSource : int -> System.Threading.CancellationTokenSource
Public Sub New (millisecondsDelay As Integer)

Parameters

millisecondsDelay
Int32

The time interval in milliseconds to wait before canceling this CancellationTokenSource.

Exceptions

millisecondsDelay is less than -1.

Remarks

The countdown for the millisecondsDelay starts during the call to the constructor. When the millisecondsDelay expires, the constructed CancellationTokenSource is canceled (if it has not been canceled already).

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

Applies to

CancellationTokenSource(TimeSpan)

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

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified time span.

public:
 CancellationTokenSource(TimeSpan delay);
public CancellationTokenSource (TimeSpan delay);
new System.Threading.CancellationTokenSource : TimeSpan -> System.Threading.CancellationTokenSource
Public Sub New (delay As TimeSpan)

Parameters

delay
TimeSpan

The time interval to wait before canceling this CancellationTokenSource.

Exceptions

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 the call to the constructor. When the delay expires, the constructed CancellationTokenSource is canceled, if it has not been canceled already.

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

Applies to

CancellationTokenSource(TimeSpan, TimeProvider)

Source:
CancellationTokenSource.cs
Source:
CancellationTokenSource.cs

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified TimeSpan.

public:
 CancellationTokenSource(TimeSpan delay, TimeProvider ^ timeProvider);
public CancellationTokenSource (TimeSpan delay, TimeProvider timeProvider);
new System.Threading.CancellationTokenSource : TimeSpan * TimeProvider -> System.Threading.CancellationTokenSource
Public Sub New (delay As TimeSpan, timeProvider As TimeProvider)

Parameters

delay
TimeSpan

The time interval to wait before canceling this CancellationTokenSource.

timeProvider
TimeProvider

The TimeProvider with which to interpret the delay.

Exceptions

delay's TotalMilliseconds is less than -1 or greater than MaxValue - 1.

timeProvider is null.

Remarks

The countdown for the delay starts during the call to the constructor. When the delay expires, the constructed CancellationTokenSource is canceled, if it has not been canceled already. Subsequent calls to CancelAfter will reset the delay for the constructed CancellationTokenSource, if it has not been canceled already.

Applies to