Book review: C# 2008 and 2005 Threaded Programming
This is the second book I have read in multithreading programming (the first was the exceptional Concurrent Programming in Windows, by Joe Duffy). As I've said in the past, this is a topic which really interests me and that's why I gladly accepted a free copy from Packt for review. As you can see from its title, this is (essentially) a beginners book. It's full of code snippets and instructions of where to put that code (where you’re supposed to build demo projects by following the steps detailed in the book). This kind of organization doesn't really appeals to me... I'd really prefer to see everything together than have code mixed with instructions (this is personal, since I do prefer to read a book away from the PC and, in this case, having instructions detailing what I need to do step by step isn't really something I enjoy).
The book has a couple of intro chapters which give you some information about the hardware and introduces you to threads and processes. After that, you quickly jump into code examples. You'll jump right into C# windows forms code and you'll start by using a BackgroundWorker object to add asynchronous behavior to your app. In fact, this was really a surprise to me because I never thought a beginners book would jump right into a Windows Forms apps. I'd really prefer to start from a console app because that would let me concentrate on threading itself instead of wasting lots of lines with UI code (I'm not saying that using the BackgroundWorker isn't important; just questioning if that is really the first practical thing you should put in a beginners threading book). I guess that it's fair to say that this is mostly a Windows Forms multithreading book since most (if not all) of its examples are windows forms examples.
Going back to the content, I did like the parts where the author showed how to use some tools (ex.: Process Explorer) for getting info on what's happening and I did found value in chapter 5, where the author presents some tips for debugging multithreaded code. Adding a chapter on Parallel Extensions was also a good idea, though I think that there definitely was a lot more to say about it (though I guess that the size of the book might have limited the author to the stuff that is presented on that chapter).
Now, here are some of the topics I expected to see mentioned on this book (and weren't or weren't well covered):
- Memory model: no, I didn't expect to find many lines on this (since it's an introductory book). But it should have been mentioned because it explains why a lot of things might go wrong in multithreading programming.
- Data synchronization: I expected to find info on this topic. It's really important in multithreading scenarios and I guess that it should have at least one chapter on it (I believe that presenting Monitor, Reader/writer locks are far more important than reusing BackgroundWorker across several chapters). I'm not sure why, but I think that there are noo examples of lock usage (which is something that really made me sad). On the other hand, being able to partition your work so that all the parts can run independently is really something which we must all try to achieve (and the author does give a lot of emphasis on that). Just wished that this portioning would be complemented with info on how to synchronize data access since that will be needed in the "real world".
- APM: the asynchronous programming model based on delegates and the event-based asynchronous pattern deserved to have a chapter about them.
Bottom line: I that think this book could be improved if it had more info in the previous topics and less stories/printed code+instructions. Btw, I didn't really enjoy the stories on the FBI agents or NASA either...if the idea was to mimic the style of the head first series, then it wasn't really achieved. Having said all this, I guess I can't really give it more than 6/10.