views:

396

answers:

6

Can you recommend a good series of articles or preferably a book on how to get started with threading in general and in C# in particular? I am primarily looking for the use of threads in console applications and in ASP.Net apps.

I understand only the very basics of threads and know that "here be dragons", so want to get a good grounding in it before I start using them.

Things I am curious about are things like the concept of having a threadpool, how you manage the size of it, how you choose for things to be queued until a thread is available vs forcing a new thread to start etc. Also, I understand that IIS has lots of built-in thread handling, so anything that explains how to work with threads in ASP.Net under IIS and how it differs from threading in a console C# applicaion is interesting.

My intended usage includes things like;

  • The user does something on the ASP.Net page that causes my server-side code to need to connect to another system and carry out lengthy operations, so I want to return control to the user quickly by firing that action to another thread. The user can keep watching progress through AJAX or simply move away - the web is stateless after all :)

  • Use of Fire and Forget patterns (lots of sample code out there, I want to understand more about how they work)

Thanks

+5  A: 

Here is a good set of articles by our very own Jon Skeet:

http://www.yoda.arachsys.com/csharp/threads/

Andrew Hare
This is what I use for all C# threading questions I have.
Jon Tackabury
You should be aware that it was written before .NET 2.0 came out though, which is why there's nothing about BackgroundWorker (IIRC). I really ought to update it some time.
Jon Skeet
+1 Jon T: Me too, just happened two days ago while transfer bulk of data from gridview to excel sheet, and because skeet's article i do it async in a five minutes. thanks Jon.
Abdullah BaMusa
+7  A: 

As well as my own articles linked by Andrew, Joe Albahari has another tutorial.

If you want a really thorough examination, read Joe Duffy's Concurrent Programming in Windows.

Jon Skeet
I just posted the same answer and have now deleted it to upvote yours instead, because you beat me to it.
Peter Morris
I'm working through Duffy's book as I have time. So far its excellent and I like his no-nonsense writing style.
Brian Ensink
+1 for the Albahari link, thanks!
Robert Lamb
+3  A: 

I found this free ebook by Joseph Albahari really useful

Paul Nearney
+1  A: 

I would recommend the series by Joseph Albahari available here:

http://www.albahari.com/threading/

It's concise and very readable.

Drew Noakes
+1  A: 

I'd recommend the following

Great MSDN Article

Charles Bretana
A: 
Jason Jackson