Parallel Dotnet

Tags:

Discover the core multithreading and parallelization concepts supported by the .NET framework.

Last updated 2022-01-10 | 4.6

- Create and run independent tasks
- Manage synchronized access to data
- Effectively use parallel collections

What you'll learn

Create and run independent tasks
Manage synchronized access to data
Effectively use parallel collections
Work with task continuations
Write parallel loops
Leverage the power of Parallel LINQ
Master asynchronous programming (async/await)

* Requirements

* Basic knowledge of C# and .NET framework
* Basic knowledge of multithreading

Description

This course is about .NET Parallel Programming with C# and covers the core multithreading facilities in the .NET Framework, namely the Task Parallel Library (TPL) and Parallel LINQ (PLINQ).

This course will teach you about:

  • Task Programming: how to create and run tasks, cancel them, wait on them and handle exceptions that occur in tasks.

  • Data Sharing and Synchronization, ensuring your access to shared data also happens in a safe and consistent manner.

  • Concurrent Collections, such as ConcurrentBag, which operate correctly even when accessed from multiple threads.

  • Task Coordination concepts, including the idea of continuations, as well as uses of synchronization primitives to coordinate tasks.

  • Parallel Loops which let you easily iterate over a counter or collection while partitioning the data and processing it on separate threads.

  • Parallel LINQ, the parallel version of .NET's awesome Language-Integrated Query (LINQ) technology.

  • Async/Await and .NET's support for asynchronous programming.

This course is suitable for:

  • Beginner and experienced .NET/C# developers

  • Anyone interested in multi-threading, parallelism and asynchronous programming

The course consists of the following materials:

  • Video lectures showing hands-on programming

  • C# files that you can download and run

Before taking the course, you should be comfortable with the C# programming language and familiar with multi-threading.

Who this course is for:

  • Beginner and experienced .NET developers
  • Computer Science students
  • Anyone interested in modern approaches to multithreading/parallelism

Course content

9 sections • 54 lectures

Course Introduction Preview 02:37

Some information about the course author, what the course contains, how the material is presented and what you need to know before taking part in the course.

Overview Preview 00:49

An overview of all the lectures in this section.

Creating and Starting Tasks Preview 10:11

An introduction to the Task abstraction, with examples of how to create and start tasks.

Cancelling Tasks Preview 11:50

A look at .NET's special CancellationTokenSource and CancellationToken classes that are used to cooperatively cancel running tasks.

Waiting for Time to Pass Preview 04:32

If you're inside a task and want to wait a while, there are ways to do this besides Thread.Sleep().

Waiting for Tasks Preview 06:51

How to wait on a single task or, indeed, a set of tasks.

Exception Handling Preview 05:25

If an exception is thrown inside a Task, who catches it, and how?

Summary Preview 06:48

A summary of key concepts from this section's lectures.

Overview Preview 03:10

An overview of the lectures in this section.

Critical Sections Preview 06:31

The lock keyword and what it means.

Interlocked Operations Preview 04:45

Atomic operations on primitive values.

Spin Locking and Lock Recursion Preview 09:30

A lock that doesn't yield.

Mutex Preview 12:11

One of the key WaitHandle-based synchronization structures.

Reader-Writer Locks Preview 09:56

A look at reader-writer locks, including upgradeability and recursion support.

Summary Preview 04:41

A summary of the lectures in this section.

Overview Preview 01:11

An overview of lectures in this section.

ConcurrentDictionary Preview 14:08

A thread-safe dictionary.

ConcurrentQueue Preview 02:54

A thread-safe queue.

ConcurrentStack Preview 04:01

A thread-safe stack.

ConcurrentBag Preview 05:46

A collection which is similar, in principle, to a thread-safe List except it doesn't preserve the order. Thus it's called a Bag.

BlockingCollection and the Producer-Consumer Pattern Preview 11:22

BlockingCollection is a special wrapper around the producer-consumer collection that is capable of blocking the producer thread until a value is available, and is capable of exposing a 'consuming enumerable' that blocks the consumer until there's an item for it to consume.

Summary Preview 01:48

A summary of materials from the lectures in this section.

Overview Preview 01:27

An overview of lectures in this section.

Continuations Preview 05:29

Different forms of continuations exist.

Child Tasks Preview 06:17

Child tasks are tasks whose lifetime are joined to those of the parent.

Barrier Preview 09:22

A useful sync primitive for coordinating multi-phase algorithms.

CountdownEvent Preview 05:29

A simple sync primitive with a counting-down value.

ManualResetEventSlim and AutoResetEvent Preview 07:03

Ordinary signals which, depending on whether they are set or not, block or unblock a thread.

SemaphoreSlim Preview 05:22

A complicated sync data structure which allows increasing/decreasing a counter to control how many threads can be executing at the same time.

Summary Preview 05:36

A summary of materials from the lectures in this section.

Overview Preview 01:19

An overview of lectures in this section.

Parallel Invoke/For/ForEach Preview 08:25

Parallel loops... what could be simpler?

Breaking, Cancellations and Exceptions Preview 09:41

Learn to break out of or cancel parallel loops, and what happens if an exception is thrown.

Thread Local Storage Preview 06:54

Concurrent access from all tasks on each iteration to a variable is very inefficient. Why not access it once per task, and keep a task-local store of intermediate results that incurs no sync overhead?

Partitioning Preview 07:45

Creating a delegate on each Task invocation is inefficient, but if we tell .NET how we want to partition data, we may end up with a much faster method.

Summary Preview 03:44

A summary of materials from the lectures in this section.

Overview Preview 01:40

An overview of lectures in this section.

AsParallel and ParallelQuery Preview 08:55

AsParallel() turns an IEnumerable<T> into a ParallelQuery<T>

Cancellation and Exceptions Preview 06:24

Just like with Task and Parallel.Xxx, PLINQ takes cancellation tokens and throws either AggregateException or OperationCancelledException.

Merge Options Preview 04:20

How quickly do you want your data? Or should PLINQ cluster results together and return them in batches?

Custom Aggregation Preview 04:26

LINQ Aggregate() function has a special PLINQ overload.

Summary Preview 01:16

Overview Preview 14:04

A detailed description of async/await mechanics.

Using Async and Await Preview 10:58

A look at async/await in action... in a WinForms app.

State Machines Preview 04:06

Behind the scenes, async methods get their associated state machines.

Task.Run Preview 06:00

Learn what Task.Run is used for.

Task Utility Combinators Preview 01:48

Learn about Task.WhenAny/WhenAll.

Async Factory Method Preview 05:01

C# doesn't have async constructors (yet), but factory methods are the next best thing.

Asynchronous Initialization Pattern Preview 04:46

A generalized way of indicating that your classes require asynchronous initialization.

Asynchronous Lazy Initialization Preview 05:51

We all love Lazy<T>, but can it play nice with async methods?

ValueTask Preview 10:18

A brand new class introduced in .NET Core, ValueTask is a lightweight alternative to Task.

Summary Preview 01:18

A summary of all the things we've learned in this section of the course.

Course Summary Preview 02:04

A summary of materials from the lectures in this section.

Bonus Lecture: Other Courses at a Discount Preview 00:13

Links to my other courses.