ThreadState

ThreadState ECMA 1.0, serializable, flag

System.Threading (mscorlib.dll) enum

This enumeration encapsulates the various states a thread may be in. A thread starts in the Unstarted state. Once the Thread.Start( ) method is called, a thread enters the Running state. If another thread calls Thread.Abort( ) at any time, the thread shifts into the AbortRequested state, and then into Aborted once the thread reaches a safe point for garbage collection.

If the running thread calls either the static method Thread.Sleep( ) , any of the Wait( ) methods on a WaitHandle , or Thread.Join( ) on another thread, the executing thread enters the WaitSleepJoin state.

If another thread calls Thread.Interrupt( ) on a thread in the WaitSleepJoin state, the thread again enters the Running state. When another thread calls Thread.Suspend( ) on a thread, it enters the SuspendRequested state. Once a thread in the SuspendRequested state reaches a safe point for garbage collection, it enters the Suspended state. A thread then leaves the Suspended state and enters the running state when another thread calls Thread.Resume( ) on it. When a thread has finished running, it enters the Stopped state.

Once a thread has started, it cannot return to the Unstarted state. Similarly, once a thread has aborted or stopped, it cannot return to the Running state. This enumeration is marked with a [Flags( )] attribute, which allows a thread to be in more than one state at a time. For example, if a thread is in the WaitSleepJoin and another thread calls Thread.Abort( ) on it, it will be in both the WaitSleepJoin and AbortRequested states at the same time.

 public enum  ThreadState  {  Running = 0x00000000  ,  StopRequested = 0x00000001  ,  SuspendRequested = 0x00000002  ,  Background = 0x00000004  ,  Unstarted = 0x00000008  ,  Stopped = 0x00000010  ,  WaitSleepJoin = 0x00000020  ,  Suspended = 0x00000040  ,  AbortRequested = 0x00000080  ,  Aborted = 0x00000100  } 

Hierarchy

System.Object System.ValueType System.Enum(System.IComparable , System.IFormattable , System.IConvertible) ThreadState

Returned By

Thread.ThreadState



C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net