Delay Method (Int32, CancellationToken)
Collapse the table of content
Expand the table of content

Task.Delay Method (Int32, CancellationToken)

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

Creates a Task that will complete after a time delay.

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

'Declaration
Public Shared Function Delay ( _
	millisecondsDelay As Integer, _
	cancellationToken As CancellationToken _
) As Task

Parameters

millisecondsDelay
Type: System.Int32
The number of milliseconds to wait before completing the returned Task
cancellationToken
Type: System.Threading.CancellationToken
The cancellation token that will be checked prior to completing the returned Task

Return Value

Type: System.Threading.Tasks.Task
A Task that represents the time delay

ExceptionCondition
ArgumentOutOfRangeException

The millisecondsDelay is less than -1.

ObjectDisposedException

The provided cancellationToken has already been disposed.

If the cancellation token is signaled before the specified time delay, then the Task is completed in Canceled state. Otherwise, the Task is completed in RanToCompletion state once the specified time delay has expired.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft