Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Task::Delay Method (TimeSpan)

.NET Framework 4.6 and 4.5

Creates a task that completes after a specified time interval.

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

public:
static Task^ Delay(
	TimeSpan delay
)

Parameters

delay
Type: System::TimeSpan

The time span to wait before completing the returned task, or TimeSpan.FromMilliseconds(-1) to wait indefinitely.

Return Value

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

ExceptionCondition
ArgumentOutOfRangeException

delay represents a negative time interval other than TimeSpan.FromMillseconds(-1).

-or-

The delay argument's TotalMilliseconds property is greater than Int32::MaxValue.

After the specified time delay, the task is completed in TaskStatus::RanToCompletion state.

For usage scenarios and additional examples, see the documentation for the Delay(Int32) overload.

This method depends on the system clock. This means that the time delay will approximately equal the resolution of the system clock if the delay argument is less than the resolution of the system clock, which is approximately 15 milliseconds on Windows systems.

The following example shows a simple use of the Delay method.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8
Show:
© 2015 Microsoft