What is the value of the ThreadState property?

This question made me think of the .NET equivalent. What does a property ThreadStateof the Thread class have? In this code example:

if (someThread.ThreadState != System.Threading.ThreadState.Running)
{
    someThread = new Thread(SomeMethod);
    someThread.Start();
}

A property someThread ThreadStatecan switch Runningbetween ifand with code inside if, right?

+3
source share
3 answers

ThreadState is one of those fantastic properties that at first looks promising, but as soon as you delve deeply into how in the functions, you will find that it is almost completely useless.

ThreadState - . , ThreadState.Runnning. , , . , - .

, . . , , .

.

, , , . , WaitHandle. , .

+4

MSDN:

:
     , System.Threading.ThreadState System.Diagnostics.ThreadState.      .      .

+2

ThreadState , /. , , - , , , ThreadState ThreadState.WaitSleepJoin.

, . , , , , , , .

+1

Source: https://habr.com/ru/post/1710722/


All Articles