Threads

When we compile and run a project in C#, the program is executed in its own process. A process has its own address space, memory assigned to it. The executable code is in the address space. A modern computer executes several processes at a time, switching between them every so often.

The idea of a thread is that one process could be split into several parts, each being executed "at the same time". They all live in the same address space and they are executing the same excutable code, though not the same part of it.

For example, a web browser may be displaying data (and responding to the user moving the mouse, etc.) while it is "simultaneously" downloading more data. This would require at least two threads.

A process always starts out as one thread, executing Main(). It can create more threads which then run independently, taking turns during tiny time slices.


Thread Class

This is in the System.Threading namespace.

Constructors (some of them)

Properties (some of them)

Methods (some of them)