Threads Life Cycle 14 March 2008
Posted by Ahmed Abdul Moniem in General Articles.trackback
When a thread is scheduled for execution it can go through several states, including unstarted, alive, sleeping, etc. The Thread class contains methods that allow you to start, stop, resume, abort, suspend, and join (wait for) a thread. We can find the current state of the thread using its ThreadState property, which will be one of the values specified in the ThreadState enumeration:
-
Aborted – The thread is in the stopped state, but did not necessarily complete execution
-
AbortRequested – The Abort() method has been called but the thread has not yet received the System.Threading.ThreadAbortexception that will try to terminate it – the thread is not stopped but soon will be.
-
Background – The thread is being executed in the background
-
Running – The thread has started and is not blocked
-
Stopped – The thread has completed all its instructions, and stopped
-
StopRequested – The thread is being requested to stop
-
Suspended – The thread has been suspended
-
SuspendRequested – The thread is being requested to suspend
-
Unstarted – The Start() method has not yet been called on the thread
-
WaitSleepJoin – The thread has been blocked by a call to Wait(), Sleep(), or Join()
Comments»
No comments yet — be the first.