C# Threading in real-world apps

GilliVilla picture GilliVilla · Aug 5, 2010 · Viewed 7.9k times · Source

Learning about threading is fascinating no doubt and there are some really good resources to do that. But, my question is threading applied explicitly either as part of design or development in real-world applications.

I have worked on some extensively used and well-architected .NET apps in C# but found no trace of explicit usage.Is there no real need due to this being managed by CLR or is there any specific reason?

Also, any example of threading coded in widely used .NET apps. in Codelplex or Gooogle Code are also welcome.

Answer

SLaks picture SLaks · Aug 5, 2010

The simplest place to use threading is performing a long operation in a GUI while keeping the UI responsive.

If you perform the operation on the UI thread, the entire GUI will freeze until it finishes. (Because it won't run a message loop)
By executing it on a background thread, the UI will remain responsive.

The BackgroundWorker class is very useful here.