Where It All Starts: The Thread Class

The closest you can get to a “raw thread” is using the Thread class, which lives in the System.Threading namespace that will be the topic of this chapter. By “raw thread” we mean a native (as all of them ultimately are) thread that can run managed code but isn’t subject to lots of additional management by the CLR or any library. In particular, no techniques such as pooling or specialized scheduling are employed.

Creating Threads

Use of the Thread class is pretty simple. We start by looking at the instance members defined on the Thread class, so we need to create an instance first. All a thread object needs to know about is what code it has to run. As you should infer by now, the idea of delegating execution ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.