Jump to ratings and reviews
Rate this book

Concurrency in C# Cookbook: Asynchronous, Parallel, and Multithreaded Programming

Rate this book
If you're one of many developers still uncertain about concurrent and multithreaded development, this practical cookbook will change your mind. With more than 85 code-rich recipes in this updated second edition, author Stephen Cleary demonstrates parallel processing and asynchronous programming techniques using libraries and language features in .NET and C# 8.0.

Concurrency is now more common in responsive and scalable application development, but it's still extremely difficult to code. The detailed solutions in this cookbook show you how modern tools raise the level of abstraction, making concurrency much easier than before. Complete with ready-to-use code and discussions about how and why solutions work, these recipes help you:


Get up to speed on concurrency and async and parallel programming
Use async and await for asynchronous operations
Enhance your code with asynchronous streams
Explore parallel programming with .NET's Task Parallel Library
Create dataflow pipelines with .NET's TPL Dataflow library
Understand the capabilities that System.Reactive builds on top of LINQ
Utilize threadsafe and immutable collections
Learn how to conduct unit testing with concurrent code
Make the thread pool work for you
Enable clean, cooperative cancellation
Examine scenarios for combining concurrent approaches
Dive into asynchronous-friendly object-oriented programming
Recognize and write adapters for code using older asynchronous styles

251 pages, Paperback

First published January 22, 2014

121 people are currently reading
360 people want to read

About the author

Stephen Cleary

3 books8 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
111 (36%)
4 stars
129 (42%)
3 stars
49 (16%)
2 stars
12 (3%)
1 star
0 (0%)
Displaying 1 - 28 of 28 reviews
Profile Image for Moe.
13 reviews6 followers
January 17, 2020
There are quite a few mistakes in the book. There is an errata of this book out there that explains the typos and the compilation errors - so some examples will not work.

For someone who has no understanding of the concepts explained (such as Parallel, Async with Task and await, Reactive Extensions) then you would need to complement the material here with other books or video tutorials. Reason being is because the way these concepts are explained was a bit difficult to grasp at first. However, I did like the examples given and its use cases.
Profile Image for Rene Stein.
228 reviews36 followers
June 3, 2014
Knihu jsem přečetl v "preview" verzi, takže je možné, že papírová kniha bude lepší.

Na knihu od Stephena Clearyho jsem se těšil, ale netuším, pro koho je určena. Autor popisuje v samostatných "receptech", které připomínají krátké blogspoty, klíčová slova async a await v C#, TPL, RX Framework i TPL Dataflow. Pochybuju, že ten, kdo o těchto knihovnách moc neví, tak se z krátkých kapitol naučí knihovny používat, nebo alespoň pochopí, proč by se o ně měl zajímat, a pro čtenáře, kteří hledají pokročilá témata, je v knize minimum textu.

Lepší je Clearyho blog.

Profile Image for Tomasz Jaskula.
Author 3 books15 followers
October 9, 2017
This book contains a series of recipes around different kind of problems for concurrent and asynchronous programming mostly seen in c#. The author goes deeper into the technical details when needed but the book still remains easy to read. I would recommend it as an additional learning ressource
Profile Image for Dmitry.
189 reviews8 followers
April 17, 2020
In Cleary's own blog you will find a lot more interesting details but do not set your hopes too high; this small book gives nothing beyond what you can read in any general book on C#(Nagel, Schildt, Troelsen etc)
228 reviews6 followers
September 26, 2021
The book is written in a "here's a problem, and this is how you can solve it" style. As a result, it has many examples that helps understand the concepts clearly. This also assists with solidifying the basics.
Profile Image for Adrian.
156 reviews29 followers
June 8, 2020
This is one of the best books i have read so far regarding concurrency.
Although i am usually skeptical about reading books for a specific language , Stephen did a tremendous job with this one and i have already adopted a bunch of hia techniques right after reading his book.

This book is like a wikipedia for concurrency/parallelism, reactive and asynchronous programming.
The author goes to great lengths to display all kinds of nasty scenarios that you could get yourself into when developing complex code and pragmatically offers the most elegant solution(s) from worst to best.

The aspect that i loved about the book is that he doesn't focus on the basics of concurrency because as he puts it "there are a plethora of resources out there".He instead focuses on the newest frameworks and libraries (thoroughly tested by the .NET team of course) that will help you get your job done with minimal effort and headaches.
He is basically teaching the reader how to write a modern .NET application and how to leverage the goodies of the language.

He treats Rx,TPL Dataflow (mind blowing for me) , PLINQ , regular TPL , async-await , concurrent/immutable collections , events , task schedulers , synchronization contexts, cancellations , synchronization primitives and many more.

Best .NET book i have read so far and one of the best resources on concurrent programming !

"The moment you write -Thread.StartNew()- your application is gone into legacy code."
13 reviews
October 9, 2024
Что понравилось:

- небольшая книга
- понятный и лаконичный стиль изложения, без воды
- структура книги в виде рецептов для решения конкретных задач. Задачи не высосаны из пальца и действительно встречаются на практике.

Что не совсем понравилось:

- в книге заметная часть материала посвящена реактивному программированию (`Rx.NET`) и библиотеке `TPL.Dataflow`. В
своей практике я не сталкивался с ними и пока не вижу, где бы они были полезны мне в бекенд разработке. С другой
стороны было неплохо узнать о их существовании и возможной области применения.
- часть рецептов посвящена third-party библиотеке `Nito.AsyncEx` (в ее разработке участвовал автор книги). Я
предпочитаю, когда в книгах рассматриваются лишь стандартные инструменты, что делают ее чуть более
долговечной/актуальной.
- некоторым темам хотелось бы уделить чуть больше внимания (например, использование `ConfigureAwait(false)` или
продвинутых примитивов синхронизации или про `Lazy>`)
- некоторые рецепты и информация уже не столь актуальны для .NET 8. Было бы здорово, дождаться переиздания данной книги
:)

Общее впечатление:

- не жалею, что прочитал
- хотя многие вещи, описанные в книге, я уже знал, удалось структурировать знания по теме конкурентности в .net.
- книга не столько про "в глубь", сколько про "в ширь"

Оценка: 4/5
6 reviews1 follower
February 29, 2024
Not great not terrible as comrade Dyatlov might say. I believe this book needs a new edition, many of the things inside I find old concepts which not necessarily bring any value to readers trying to learn something about concurrency.

I liked the structure of the book however, this “Problem - Solution - Discusion” organization was very easy to read and skip parts if you dont feel you need to read.
Profile Image for Alex.
6 reviews
January 6, 2022
Contains a lot of practical advice and code primers. Although if you expect a lot of descriptions and theory, or simply don't have any prior experience with TPL / dotnet concurrency in general, I'd suggest to look into other books which dive into theory first
Profile Image for Ebsan.
9 reviews
January 7, 2020
Concise information with a lot of examples. Cleary put relevant information about async programming that was originally hard to find from Microsoft's docs alone.
Profile Image for Nahum Timerman.
9 reviews
August 21, 2020
Useful as a general review and a reference, but I ran out of steam trying to use all the examples in actual code.
Good to go back to when handling a problem that requires a specific solution
Profile Image for Branislav Petrović.
5 reviews
August 3, 2022
Great book for experienced C# developers to expand knowledge in areas of asynchronous, parallel and reactive programming!
Profile Image for Bob Woodley.
278 reviews3 followers
March 5, 2023
A good way to come to grips with all the concurrency constructs in C#. This is a cookbook, so you take the ones you need. A good reference to have on one's shelf.
Profile Image for Gabriel Santos.
62 reviews12 followers
October 27, 2019
It serves as an additional reading. I thought that, being a cookbook, it is rather superficial.
Profile Image for Alex.
9 reviews
November 23, 2021
After reading this book I was able to write and follow concurrency in C#. I also know the landscape of concurrent of options available. That said I think this book serves better as a quick reference for more experienced developers than a learning resource.
Profile Image for Kevin Garner.
18 reviews4 followers
July 13, 2015
Concurrency in C# Cookbook is a series of recipes, separated into 13 chapters, each beginning with some general discussion regarding the topic at hand. I needed to begin learning concurrency programming for work, and research led me to Stephen's book. While researching code smells surrounding poll-heavy while loops led me to the author's blog. Right away, I got some really good information and saw his book featured there. It's 208 pages of relevant, carefully guided material that has helped me to put together a plan for paying off some technical debt and dramatically reducing the memory footprint of some software running on our app servers. I highly recommend this book as both an introduction to concurrency programming in C# and also as a desktop reference book on various scenarios that you may encounter while working with concurrent code.
Profile Image for Sebastian Gebski.
1,186 reviews1,337 followers
October 2, 2014
Quick, tidy reference of modern (no direct Thread/ThreadPool manipulation) approach to parallel, concurrent & async processing using C#. In a clean & structured form of short cookbook recipes. Doesn't dive deep, but presents you what you should know to start using particular lib / syntax. In my case it was a great refreshment after coming back from functional world (mainly on JVM) + I've finally read up something more about TPL DataFlow - the area I've somehow managed to skip until now.

To summarize: don't expect wonders, but if you just want an overview to actually start coding (there's no other way of learning how to write concurrent programs - reading is NOT ENOUGH), this book ain't a bad pick.
Profile Image for Robson Castilho.
266 reviews32 followers
February 8, 2016
As a "cookbook", this book follows the pattern "problem/solution/discussion" showing how to solve problems related to concurrent code with minimal theory. So if you want to get deeper knowledge about its topics, this is NOT the book for you.

If you're working (or about to work) with concurrency, this book may help you with practical tips about async/wait, Parallel, Rx, immutable/thread-safe collections and the like. Even if you're not working with concurrency, it helps as a quick introduction to the basics of the topic.
Profile Image for Nemantro.
43 reviews1 follower
July 9, 2020
Excellent reference for those who are looking for successful receipes when playing with concurrency in C#.

Stephan Cleary is an extraordinary teacher with a huge knowledge on the concurrency subjet, and a remarkable background in developement.

There are some parts of the book I didn't read, some others I won't use. The content is clearly presented and detailed. A book to recommend.
Profile Image for Jakub.
270 reviews
September 26, 2014
its good to have it on shelf but its not worth it reading it as "normal" book. rather come back to it when you need advice, however prob. stack overflow would be able to help much faster and better. if you do not know anything about used technology and terminology, including frameworks.
4 reviews
January 1, 2017
The book is exactly what it says is: a cookbook. So don't expect detailed explanation of how things work behind the scenes, or too academic explanation. You should expect quick explanation of classes and features and how to use them and when.
Profile Image for John Nicholson.
13 reviews
July 20, 2020
This is by a long way the best book out there on multi threading task and other concurrent problems in C#. this is a reference that has been on my desk for a couple of years and help guide quite a few of my team to make better choices and get more out our systems.
Profile Image for Vladislav.
7 reviews
May 11, 2020
Very useful book. Only good useful and actual information about all kind of modern .Net Concurrency, including .Net Core. Useful reciepts.
Book will be good for beginners or non experts in concurrency. You don't find any deep diving here.
Profile Image for Mike Harris.
218 reviews4 followers
June 5, 2020
This book is somewhere between a coding cook book and an applied concept book. It goes into a decent amount of detail around the different approaches to concurrent programming with C#. It is not as in depth as an advance book but you will learn a lot from it despite its low page count.
Profile Image for Vlad Bezden.
236 reviews14 followers
May 26, 2015
Overall it's a very good book. I wish it had more and better examples instead of just excerpts. I also wish it had more theory behind, not just how to solve the issue.
Profile Image for Vzh.
27 reviews1 follower
August 8, 2020
Short recipes, many angles and libraries mentioned.
Displaying 1 - 28 of 28 reviews

Can't find what you're looking for?

Get help and learn more about the design.