Share via

Thread.Sleep Method (Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Suspends the current thread for a specified time.

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


<SecuritySafeCriticalAttribute> _
Public Shared Sub Sleep ( _
    millisecondsTimeout As Integer _
public static void Sleep(
    int millisecondsTimeout


  • millisecondsTimeout
    Type: System.Int32
    The number of milliseconds for which the thread is blocked. Specify 1 (one) to yield to other threads that might be waiting to execute. (We recommend a wait of 1 instead of a wait of 0.) Specify Timeout.Infinite to block the thread indefinitely.


Exception Condition

The time-out value is negative and is not equal to Timeout.Infinite.


The thread will not be scheduled for execution by the operating system for the amount of time specified. This method changes the state of the thread to include WaitSleepJoin.

Important noteImportant Note:

Do not call Sleep from the main application thread in your Silverlight-based application. Doing so makes the user interface (UI) unresponsive, blocks DispatcherTimer and BackgroundWorker events, and blocks cross-thread calls to the UI thread that were made by using Dispatcher.

This method does not perform standard COM and SendMessage pumping.


If you need to sleep, but you want to perform standard COM and SendMessage pumping, consider using one of the overloads of the Join method that specifies a time-out interval. For example, replace Sleep(1000) with Thread.CurrentThread.Join(1000).

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.