I have recently updated the ‘C# Fundamentals’ course available for free personal and academic usage at www.abelski.com adding slides about the new multithreading capabilities added in .NET 4.0. The following video clips present those new capabilities.
Parallelism can be achieved on multi core machines only. Multithreading can be achieved on single core machine as well. The Parallel new class (added in .NET 4.0) allows us to benefit parallelism. The following video clips shows how to do it.
The Task class represents the work we want to complete. Its methods allow us to create, schedule and synchronize tasks in our code. The following video clips show how to use this class.
The Barrier class can assist us when we have a set of two (or more) threads that a pre defined number of them first need to complete or reach a specific point in their execution before a specific other thread can continue its execution. The following clip shows and explains how to use it.
The CountDownEvent class allows us having a coundown counter that holds a specific thread in a wait state till it reaches 0. Different threads can access and decrease its value by calling the Signal() method. Each time the Signal() method is called the counter value is decreased by one. The following video clips show and explains how to use this class.