ÎÜñ|‹ø\/\/ñ [ÐëÞrëçã†ëð]'s Blog

Amit Bahree's insight into stuff...

News

And God said "Let there be light". But then the program crashed because he was trying to access the 'light' property of a NULL universe pointer.

blog roll

calendar

intersting finds

reading

techy finds

How to find if a thread is running using the ThreadState property?

If you wanted to use the ThreadState property (which should only be used for debugging and not sync.), to find out if a thread is running. Since the Running state has a value of 0, you cannot do a bit test to discover this state. But you could do something like this to get the same result:

if ((state & (Unstarted | Stopped)) == 0) //yea, its Running!