Delay Method (TimeSpan)

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
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function Delay (
	delay As TimeSpan
) As Task


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.

Exception Condition

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


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.

Imports System.Threading.Tasks

Module Example
   Public Sub Main()
      Dim t = Task.Run(Async Function()
                                Await Task.Delay(TimeSpan.FromSeconds(1.5))
                                Return 42
                       End Function)
      Console.WriteLine("Task t Status: {0}, Result: {1}",
                        t.Status, t.Result)
   End Sub
End Module
' The example displays the following output:
'       Task t Status: RanToCompletion, Result: 42

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft