NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ThreadState Enumeration

Specifies the state of a thread.

A thread can be in multiple states at the same time. The property ThreadState provides a bit mask indicating the thread's current state. A thread is always in at least one of these possible states in the ThreadState enumeration.

[Visual Basic]
Public Enum ThreadState
[C#]
public enum ThreadState
[C++]
public enum ThreadState

[JScript] In JScript, you can use the enumerations in the NGWS frameworks, but you cannot define your own.

Remarks

Threads created within the Runtime are initially in the unstarted state. The thread remains in the unstarted state until it is transitioned into the started state by calling Start. External threads that wander in to the Runtime are already in the started state. Once in the started state, there are a number of actions that can cause the thread to change states. The following table lists the actions that cause a change of state along with the corresponding new state.

Action StateTransition
Another thread calls Thread.Start <>
The thread starts running Running
The thread calls Thread.Sleep WaitSleepJoin
The thread calls Monitor.Wait on another object WaitSleepJoin
The thread calls Thread.Join on another thread WaitSleepJoin
Another thread calls Thread.Suspend SuspendRequested
The thread responds to a Thread.Suspend request Suspended
Another thread calls Thread.Resume Running
Another thread calls Thread.Stop StopRequested
Another thread calls Thread.Interrupt Running
The thread responds to a Thread.Stop request Stopped
Another thread calls Thread.Abort AbortRequested
The thread response to a Thread.Abort Aborted

It is often the case that a thread is in more than one state at any given time. For example, if a thread is blocked on a call to Wait and another thread calls Stop on that same thread, the thread will be in both the WaitSleepJoin and the StopRequested states at the same time. In that case, as soon as the thread returns from the call to Wait or is interrupted, it will receive the ThreadStopException.

Once a thread leaves the unstarted state as the result of a call to Start, it can never return to the unstarted state. A thread can never leave the stopped state, either.

Members

Member Name Description
Aborted [To be supplied.]
AbortRequested [To be supplied.]
Background [To be supplied.]
Running [To be supplied.]
Stopped [To be supplied.]
StopRequested [To be supplied.]
Suspended [To be supplied.]
SuspendRequested [To be supplied.]
Unstarted [To be supplied.]
WaitSleepJoin [To be supplied.]

Requirements

Namespace: System.Threading

Assembly: mscorlib.dll

See Also

System.Threading Namespace