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

Task.Delay Method (TimeSpan, 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 ( _
	delay As TimeSpan, _
	cancellationToken As CancellationToken _
) As Task

Parameters

delay
Type: System.TimeSpan
The time span 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 delay is less than -1 or greater than Int32.MaxValue.

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