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.

 

«August»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456