(2003 to 2005)

Design Patterns for Multi-Threading on .NET

Wed Dec 10 10:29:00 UTC+1100 2003


I discovered (albiet a little bit later than the rest of the world) Eric Gamma's Design Patterns earlier this year.

One thing that I remember that he pointed out early, was that he wasn't going to address multi-threading patterns, although he thought it would be a good idea for someone to do. Since then it's been in the back of my mind to find material on this.

I've found two particularly good articles on this topic relevant to the .NET framework so far. Both spring from DevelopMentor.

The first one is a particularly good article, in the form of a presentation, .NET Windows Forms Development and Deployment.

The other one is some sample code, made available by Mike Woodring from the DevelopMentor website.

I fell in love with the elegance and simplicity of code like this the first time I saw it:

private void OnSomeEvent(IAsyncResult ar) {
if (this.InvokeRequired) { AsyncCallback cb = new AsyncCallback(this.OnSomeEvent); this.BeginInvoke(cb, new object[] { ar } ); return; }
this.Text = "Some Event..";

Don't forget the golden rule of Win32 programming: “Only use a Control on the thread on which it was created”.


Copyright © 2003-2005 John Elliot