Determining a Threads State


Determining a Thread’s State

The state of a thread can be obtained from the ThreadState property provided by Thread. It is shown here:

 public ThreadState ThreadState{ get; }

The state of the thread is returned as a value defined by the ThreadState enumeration. It defines the following values:

ThreadState.Aborted

ThreadState.AbortRequested

ThreadState.Background

ThreadState.Running

ThreadState.Stopped

ThreadState.StopRequested

ThreadState.Suspended

ThreadState.SuspendRequested

ThreadState.Unstarted

ThreadState.WaitSleepJoin

All but one of these values is self-explanatory. The one that needs some explanation is ThreadState.WaitSleepJoin. A thread enters this state when it is waiting because of a call to Wait( ), Sleep( ), or Join( ).




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

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