I was going to write a post on the different ways to execute code asynchronously in .NET, the pros and cons.  You know, BeginInvoke, QueueUserWorkItem, the new BackgroundWorker class, the direct thread creation…  Before doing that, I wanted to check out if somebody has already done similar posting, and I came across this jewel from Julia Lerman with Michael Cambell’s (as a feedback).   Strongly recommended!  You can find it at http://blog.ziffdavis.com/devlife/archive/2005/12/21/39532.aspx.

 

Summary: it may be possible that RunWorkerCompleted event is fired on a thread different from the UI thread.  To avoid exceptions when touching UI controls, use InvokeRequired and Invoke methods, if necessary.