MultiThreading: A brave new world...sort of

I am trying for the first time to get a good grip on multithreading, and I am having trouble finding practical examples. Oh, I can find explanations (some great ones) that have helped me understand what happens, but so far nothing too "real world" in an example.

I hear you saying "Gosh, he's not really worked with multithreading before??", and the embarassing answer is no. I've always had the luxury of having the ability to write single threaded apps only. Been lucky, I guess.

So, the example I am building (and will post once I get it working) is simple, but illustrates a real world situation: I have an app with a start and stop button. Click the start button, a thread will execute running something (a long, repeating loop updating the UI) and checking the state of the app. The stop button, on the main thread, will control the state of the app. This simulates the sort thing you'd see in any number of apps where some long process can be easily interrupted.

I have found some great explanations of how it is supposed to work. Check out

this book by Christian Gross for a good one. This book, btw, might be a little misnamed; it seems to be a little random and less about C# than about .Net. It has some good, concise explanations and discussions of selected topics in the .Net world. Reviews online have really torn this book up, but I think taken in context, it's pretty handy.

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
Print | posted on Tuesday, August 12, 2008 8:15 AM

Feedback

# re: MultiThreading: A brave new world...sort of

left by Jonathan Starr at 8/12/2008 7:42 PM Gravatar
I think you will have fun with multi-threading, Theo. The biggest challenge will come from debugging the application - which is your specialty! (I generally will build an integration test that goes through the happy path of the app that is single threaded to flush out obvious problems. Also you should become familiar with ALT-CTRL-E in VS (beak an exception when thrown)... You will want to see common language runtime exceptions when thrown if you are logging and then eating exceptions in a multi-threaded app...)

Also I suggest that you take a look at PLINQ when you get a chance.

My company is doing grid computing which is basically multi-threading over a network of computers We are using the Appistry framework which has a free download version if you are interested.

Hoping you are doing well,

Jonathan Starr
Comments have been closed on this topic.