public enum ThreadState
Object
ValueType
Enum
ThreadState
mscorlib
BCL
Specifies the execution states of a Thread.
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 ofThreadState
values are valid; for example, a thread cannot be in both the System.Threading.ThreadState.Stopped and System.Threading.ThreadState.Unstarted states.The following table shows the actions that cause a thread to change state.
In addition to the states noted above, there is also the System.Threading.ThreadState.Background state, which indicates whether the thread is running in the background or foreground.
Action ThreadState after Action The thread is created Unstarted System.Threading.Thread.Start is invoked on the thread Running The thread calls System.Threading.Thread.Sleep(System.Int32) WaitSleepJoin The thread calls System.Threading.Monitor.Wait(System.Object,System.Int32,System.Boolean) to wait on an object WaitSleepJoin The thread calls System.Threading.Thread.Join to wait for another thread to terminate WaitSleepJoin The ThreadStart delegate methods finish executing Stopped Another thread requests the thread to System.Threading.Thread.Abort(System.Object) AbortRequested The thread accepts a System.Threading.Thread.Abort(System.Object) request Aborted The current state of a thread can be retrieved from the System.Threading.Thread.ThreadState property, whose value is a combination of the ThreadState values. Once a thread has reached the System.Threading.ThreadState.Stopped state, it cannot change to any other state.
FlagsAttribute
System.Threading Namespace
ThreadState Fields
ThreadState.AbortRequested Field
ThreadState.Aborted Field
ThreadState.Background Field
ThreadState.Running Field
ThreadState.Stopped Field
ThreadState.Unstarted Field
ThreadState.WaitSleepJoin Field
ThreadState.value__ Field
AbortRequested = 0x80;
The System.Threading.Thread.Abort(System.Object) method has been invoked on the thread, but the thread has not yet received the pending ThreadAbortException that will attempt to terminate it.
System.Threading.ThreadState Enum, System.Threading Namespace
Aborted = 0x100;
The thread represented by an instance of Thread has terminated as a result of a call to System.Threading.Thread.Abort(System.Object). A thread in this state is also in the System.Threading.ThreadState.Stopped state.
System.Threading.ThreadState Enum, System.Threading Namespace
Background = 0x4;
The thread represented by an instance of Thread is being executed as a background thread, as opposed to a foreground thread. [Note: This state is controlled by setting the System.Threading.Thread.IsBackground property.]
System.Threading.ThreadState Enum, System.Threading Namespace
Running = 0x0;
The thread represented by an instance of Thread has been started and has not terminated.To determine if a thread is running, check that its state does not include System.Threading.ThreadState.Unstarted and does not include System.Threading.ThreadState.Stopped.
System.Threading.ThreadState Enum, System.Threading Namespace
Stopped = 0x10;
The thread represented by an instance of Thread has terminated.
System.Threading.ThreadState Enum, System.Threading Namespace
Unstarted = 0x8;
The System.Threading.Thread.Start method has not been invoked on the thread.
System.Threading.ThreadState Enum, System.Threading Namespace
WaitSleepJoin = 0x20;
The thread represented by an instance of Thread is blocked as a result of a call to System.Threading.Monitor.Wait(System.Object,System.Int32,System.Boolean), System.Threading.Thread.Sleep(System.Int32), or System.Threading.Thread.Join.
System.Threading.ThreadState Enum, System.Threading Namespace
value__;
System.Threading.ThreadState Enum, System.Threading Namespace