how to determine the current state of a thread in C #
Sinom
In C #, the thread object thread uses the ThreadState property to indicate the thread state, which is an enumerated type object with the Flags attribute, so judging the current state of the thread must use bitmask bitwise operation to achieve the purpose of judgment, not directly using equality to judge.
The definition threadstate is as follows:
1. Determine if the thread is in a canceled state A. Wrong judgment (mythread.threadstate = = threadstate.abortrequested) B. The right judgment(myThread.ThreadState & threadstate.abortrequested)! = 0
2. Determine if the thread is in a running state threadstate.running equals 0 and cannot be used with &, so the following methods are available: (mythread.threadstate = = ThreadState. Running)
How to determine the current state of a thread in C #