In most cases, it is easiest to use the BackgroundWorker component, as suggested by itowlson, and I highly recommend using this approach if possible. If for some reason you cannot use the BackgroundWorker component for your purpose, for example, if you are working with .Net 1.1 (yikes!) Or with a compact card, you may need to use an alternative approach:
Using Winform controls, you should avoid changing controls in any thread other than the thread that originally created the control. The BackgroundWorker component handles this for you, but if you are not using it, you can and should use the InvokeRequired and Invoke properties found in the System.Windows.Forms.Control class. The following is an example of using this property and method:
public partial class MultithreadingForm : Form { public MultithreadingForm() { InitializeComponent(); }
Dr. Wily's Apprentice Jan 19 '10 at 22:31 2010-01-19 22:31
source share