TaskUtilities..::..DelaySafe Method (Int32, CancellationToken)

Creates a cancellable task that completes after a specified number of milliseconds. This will not throw an exception if the cancellationToken is triggered or disposed.

Namespace:  Tortuga.Anchor
Assembly:  Tortuga.Anchor (in Tortuga.Anchor.dll)

Syntax


public static Task DelaySafe(
	int millisecondsDelay,
	CancellationToken cancellationToken
)
Public Shared Function DelaySafe ( _
	millisecondsDelay As Integer, _
	cancellationToken As CancellationToken _
) As Task

Parameters

millisecondsDelay
Type: Int32
The number of milliseconds to wait before completing the returned task, or -1 to wait indefinitely.
cancellationToken
Type: CancellationToken
A cancellation token to observe while waiting for the task to complete.

Return Value

A task that represents the time delay.

Exceptions


ExceptionCondition
[ArgumentOutOfRangeException]The millisecondsDelay argument is less than -1.