Understanding Thread States

Starting threads, stopping threads, pausing them—these are all acts that conspire to change the state of a thread. That is, it is in a particular state before we interact with it and another state when we are done. As you might imagine, the issue of what thread is in what state can quickly become an important piece of information for you to know. It's probably time to examine all of the possible thread states. Then we'll see what we can do to affect a thread in any given state.

Querying for State Information

To find out what state any particular thread is currently in, we need to examine the ThreadState property. This property will return a bit-masked ThreadState enumeration (see Table 12.3). Why does this property ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.