Resources

Joe Duffy on reusable libraries and multi-threading
Joe Duffy is one of those people whose depth of knowledge scares me intensely. His blog is excellent, and this is a top-notch article going into all kinds of possible errors and good approaches when it comes to threading.
Asynchronous Programming Design Pattern
MSDN pages with explanations for using and providing asynchronous methods.
Brad Abram's blog entry on volatilty and memory barriers
Interesting as much for the discussion afterwards as the article itself, this discusses just what is needed to make the double-checked lock algorithm thread-safe.
An email from Vance Morrison amount the memory model
An excellent introduction to the .NET memory model, this email has one crucial cut-and-paste problem in it (acknowledged later by Vance). The first ("broken") implementation of the double-checked lock algorithm should not have a volatile variable. The volatility actually makes it thread-safe, against the intention of the author! Please bear that in mind while reading this, otherwise it makes a lot less sense.
"An Introduction to Programming with C# Threads" by Andrew Birrell
I haven't read all of this, and disagree with part of his "cheating" section (as he seems to assume that the .NET memory model is the same as the Java one, and that you therefore can't "fix" the double-check lock algorithm) but other than that, this looks very good.
Chris Brumme's blog entry on the .NET memory model
I disagree with some of the points Chris makes (as I believe it's far from impossible to write thread-safe code to the .NET memory model, so long as you don't try to do anything too clever). However, this is generally an excellent article describing some of the purpose and details of the .NET memory model.
Singleton implementation
My own page on writing a thread-safe singleton implementation. This tries to keep things somewhat simpler than some of the complicated and clever solutions given using volatile variables and explicit memory barriers.
Article by Justin Rogers about Control.*Invoke
Very detailed article about threading in Windows Forms.
Chris Brumme's blog entry on asynchronous operations
Amongst other things, this article talks about the need to call EndXXX methods except in the case of Control.BeginInvoke.
Comparing the Timer Classes in the .NET Framework Class Library
MSDN magazine article giving details of how to pick an appropriate timer, and how to use timers safely.
Advanced CLR mailing list post on threading principals
Details of a security oddity when it comes to invoking asynchronous operations.
Give Your .NET-based Application a Fast and Responsive UI with Multiple Threads
Article on multi-threading which particularly concentrates on UI issues, but also contains "the basics".
Safe Thread Synchronization
Excellent article (as always) by Jeffrey Richter.
Timed Locks
The first of many blog entries by Ian Griffiths on his quest for locks with timeouts. (The other blog entries are linked from the first.)

Previous page: Collected Hints and Tips

Back to the main C# page.