Concurrency in C# Cookbook
Concurrency in C# Cookbook

Author:  Stephen Cleary 
Publisher: O'Reilly
Pages:208 
ISBN: 978-1449367565
Print: 1449367569
Kindle: B00KCY2CB4
Audience: Experienced C# programmers
Rating:  4
Reviewer: Mike James

Concurrency is a tough topic and you need all the help you can get, hence this book needs no excuse to exist. 

 

If you think concurrency in C# then you will probably think await and async. These are the revolutionary new features in C# that make asynchronous programming as easy as synchronous programmer - by the devious trick of making it look exactly like synchronous programming. This is not what this book is about, well it is but not entirely. Notice that the title is Concurrency and the subtitle is asynchronous, parallel and multithreaded programming. So the topics covered are much bigger than simply asynchronous programming.

If you are just beginning to wonder what the difference is between these terms then Chapter 1 is for you. It goes over the basics - concurrency, asynchronous programming and parallel programming are the foundations on which everything is built. More surprisingly it also covers reactive programming and dataflows. For me this is the best part of the book because the author isn't forced into an unnatural cookbook style which really doesn't suit the topic and it doesn't inhibit Stephen Clreay's natural tendency to want to tell a story.

Chapter 2 gets into the details about async and await or rather I think that's what the author would like to do, but he has to break the material down into recipes - pausing for a period of time, reporting progress and so on. This is a shame because there are ideas to convey in how async works. In particular there is the issue of context - what is it and when can you dispense with it. Instead of an in depth discussion and explanation, what we have is a short recipe on avoiding context for continuations. There are some interesting recipes - particularly processing tasks as they complete. There are only 15 pages on the entire topic so coverage is a bit thin. 

{loadposition morebooks}

Chapter 3 moves on to parallel programming, including parallel for and parallel LINQ. Again the recipes are a poor stand-in for a detailed tutorial. Chapter 4 explains dataflow, a topic which is niche in the concurrency world. If you have a natural data flow then this is a good way to go. Next we have a chapter on reactive programming using Rx. This isn't really enough to do justice to a very interesting idea. The recipes are more about getting you to do small things like convert a .NET event or send a notification. It would be better to adopt an approach that explained the sorts of things you can do with Rx and then showed how. 

The next four chapters are on what you might call common tasks or problems. Chapter 6 deals with unit testing for each of the approaches; Chapter 7, titled "Interop", basically presents mixes of the different methods; Chapter 8 gives a set of recipes using immutable collections which of course fit together with concurrency and Chapter 9 deals with the very difficult problem of cancellation - how do you stop something once you have started a set of concurrent processes. 

 

 

 

The final part of the book deals with less common topics. Chapter 10 explains how to write functional friendly OOP with async; Chapter 11 is an almost classical topic - synchronization - and Chapter 12 is about scheduling. Finally we have something of a round out chapter explaining the sorts of places that you might use concurrency

Some cookbooks tackle subjects that lend themselves to recipes, but concurrency doesn't seem to. This is a good book which contains lots of good ways of doing things, but overall if you understand the theory well enough you probably don't need many of them. Often you find that you are reading an explanation of some recipe and you encounter a throwaway line that really needs a longer explanation in its own right - but this would be beyond the topic of the recipe. It is also too light on the basics of async and await and on RX. It would be much better to recast the material in this book into a tutorial style.

However, if you are looking for a intermediate book on concurrency in C# then this is worth adding to your library, but it is not for the beginner. 

For more recommended books see C# Books - Pick of the Shelf

 

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

 

{loadposition morebooks}

{loadposition morebooksART}

 

Last Updated ( Wednesday, 25 May 2016 )
 
 

   
Banner
RSS feed of book reviews only
I Programmer Book Reviews
RSS feed of all content
I Programmer Book Reviews
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.