Multithreading made easy with .NET 4.0 Parallel Extensions

With the growing popularity of multi-core processors, there is an increasing expectation that applications are able to utilize this power. 

Up until recently, the task of writing a robust multithreaded application was daunting to say the least. But with the addition of Parallel Extensions in .NET 4.0, it's as simple as changing a couple of lines of code.

For example, given a regular c# foreach loop:

The equivalent parallel loop is:

Parallel for each loops are just one of the many features of the Parallel Extensions library. For a complete reference refer to the book "Parallel Programming with Microsoft .NET", which you can access online for free at