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# 4.0 Unleashed 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.