Re: Visual C# General Events across threads
Peter Ritchie
It's quite common for events to be raised/handled on a different thread. For the most part it doesn't matter. When you're handling events on a Control (e.g. a Form) you have to make sure you don't do anything with the controls from a thread other than the main/GUI thread. You can detect if you're not on the main/GUI thread for a control via the InvokeRequired property. The pattern would be the InvokeRequired/BeginInvoke pattern. There's lots of detail about using that on the Net. If you have specific questions, let us know.
If you want to perform some logic in a background thread and you do have to think about updating controls either during processing or when the processing is completed, I would suggest using the BackgroundWorker class. The BackgroundWorker class provides the ability to perform logic on a background thread while supporting both progress and completed events. The progress and completed events are guaranteed to be executed on the thread that called the BackgroundWorker's RunWorkerAsync method. So, you don't have to deal with the InvokeRequired/BeginInvoke. BackgroundWorker doesn't do anything for synchronization of shared resources though, so you still have to deal with that. Again, there's lots of examples of using BackgroundWorker kicking around; but, if you have specific questions, let us know.