[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Specifies the execution states of a Thread.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Assembly: mscorlib (in mscorlib.dll)
|The thread has been started, it is not blocked, and there is no pending ThreadAbortException.|
|The thread is being requested to stop. This is for internal use only.|
|The thread is being requested to suspend.|
|The thread is being executed as a background thread, as opposed to a foreground thread. This state is controlled by setting the property.|
|The Thread..::..Start method has not been invoked on the thread.|
|The thread has stopped.|
|The thread is blocked. This could be the result of calling Thread..::..Sleep or Thread..::..Join, of requesting a lock — for example, by calling Monitor..::..Enter or — or of waiting on a thread synchronization object such as ManualResetEvent.|
|The thread has been suspended.|
|The method has been invoked on the thread, but the thread has not yet received the pending System.Threading..::..ThreadAbortException that will attempt to terminate it.|
|The thread state includes and the thread is now dead, but its state has not yet changed to .|
defines a set of all possible execution states for threads. Once a thread is created, it is in at least one of the states until it terminates. Threads created within the common language runtime are initially in the Unstarted state, while external threads that come into the runtime are already in the Running state. An Unstarted thread is transitioned into the Running state by calling Start. Not all combinations of ThreadState values are valid; for example, a thread cannot be in both the Aborted and Unstarted states.
The following table shows the actions that cause a change of state.
A thread is created within the common language runtime.
A thread calls Start
The thread starts running.
The thread calls Sleep
The thread calls on another object.
The thread calls Join on another thread.
Another thread calls
Another thread calls Suspend
The thread responds to a Suspend request.
Another thread calls Resume
Another thread calls
The thread responds to a request.
A thread is terminated.
In addition to the states noted above, there is also the Background state, which indicates whether the thread is running in the background or foreground.
A thread can be in more than one state at a given time. For example, if a thread is blocked on a call to , and another thread calls on the blocked thread, the blocked thread will be in both the WaitSleepJoin and the AbortRequested states at the same time. In this case, as soon as the thread returns from the call to or is interrupted, it will receive the ThreadAbortException to begin aborting.