This is a series of articles about Multi-threading.

A - Introduction

The first article in this series, Multi-Threading (1), Concept: What, Why, written on 01/30/2023, introduced the multi-threading concept. The following articles should be the implementations of different approaches.

The content of the article:

Note

Writing a summary article is somewhat quite difficult. Before one jumps into each topic, it is hard to have an overview; on the other hand, if writing a series of articles, when one makes them done, it seems not necessary to write a summary article.

This article on MultiThreading overview is actually my study notes recorded over decades. In the first half, I tried to make them logical, as written in the article, Multi-Threading (2), Implementation Overview, while in the second half of the article, I just simply list the topics there, written in this article. For myself, it is still a learning process; for others, one may see how others learn multi-threading.

B - Async/Await - Best Practices in Asynchronous Programming

C - Difference between Thread, ThreadPool & BackgroundWorker

D - Task vs Thread differences

Thread is a lower-level concept: if you're directly starting a thread, you know it will be a separate thread rather than executing on the thread pool, etc.

The task is more than just an abstraction of "where to run some code" though - it's really just "the promise of a result in the future". So as some different examples:

Note that the Task<T> abstraction is pivotal to the async support in C# 5.

In general, I'd recommend that you use the higher level abstraction wherever you can: in modern C# code, you should rarely need to explicitly start your own thread.

E - Threads vs. Tasks

.Net has three low-level mechanisms to run code in parallel: Thread, ThreadPool, and Task. These three mechanism serve different purposes.

F - Options for Asynchronous Programming (Pro .NET 2.0 WinForms, P695)

G - Multithreading: immutability

If we build immutable types, then everything should be a lot easier, and we don’t need to synchronize access to these items.

H - MS Threading Model

I - Asynchronous pattern

References: