Mono Class Library: System.Threading Namespace

System.Threading.ThreadState Enumeration

Specifies the execution states of a System.Threading.Thread. [Edit]
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ThreadState

Remarks

System.Threading.ThreadState defines the set of possible execution states for threads. Once a thread is created, it is in one or more of these states until it terminates. Not all combinations of ThreadState values are valid; for example, a thread cannot be in both the ThreadState.Stopped and ThreadState.Unstarted states.

The following table shows the actions that cause a thread to change state.

ActionThreadState after Action
The thread is createdUnstarted
Thread.Start is invoked on the threadRunning
The thread calls Thread.Sleep(int)WaitSleepJoin
The thread calls Monitor.Wait(object, int, bool) to wait on an objectWaitSleepJoin
The thread calls Thread.Join to wait for another thread to terminateWaitSleepJoin
The System.Threading.ThreadStart delegate methods finish executingStopped
Another thread requests the thread to Thread.Abort(object)AbortRequested
The thread accepts a Thread.Abort(object) requestAborted

In addition to the states noted above, there is also the ThreadState.Background state, which indicates whether the thread is running in the background or foreground.

The current state of a thread can be retrieved from the Thread.ThreadState property, whose value is a combination of the System.Threading.ThreadState values. Once a thread has reached the ThreadState.Stopped state, it cannot change to any other state.

[Edit]

Members

Member NameDescription
AbortedThe thread represented by an instance of System.Threading.Thread has terminated as a result of a call to Thread.Abort(object). A thread in this state is also in the ThreadState.Stopped state. [Edit]
AbortRequestedThe Thread.Abort(object) 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. [Edit]
BackgroundThe thread represented by an instance of System.Threading.Thread is being executed as a background thread, as opposed to a foreground thread.
Note: This state is controlled by setting the Thread.IsBackground property.
[Edit]
Running

The thread represented by an instance of System.Threading.Thread has been started and has not terminated.

To determine if a thread is running, check that its state does not include ThreadState.Unstarted and does not include ThreadState.Stopped.

[Edit]
StoppedThe thread represented by an instance of System.Threading.Thread has terminated. [Edit]
StopRequestedDocumentation for this section has not yet been entered. [Edit]
SuspendedDocumentation for this section has not yet been entered. [Edit]
SuspendRequestedDocumentation for this section has not yet been entered. [Edit]
UnstartedThe Thread.Start method has not been invoked on the thread. [Edit]
WaitSleepJoinThe thread represented by an instance of System.Threading.Thread is blocked as a result of a call to Monitor.Wait(object, int, bool), Thread.Sleep(int), or Thread.Join. [Edit]

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0