Click to See Complete Forum and Search --> : [RESOLVED] How to update a ToolStripProgressBar from a thread


HalD
April 2nd, 2007, 04:49 PM
I have a Windows form that has a StatusStrip that contains a ProgressBar. I want to update the ProgressBar from a thread started by the form when a treeview item is clicked on. I set up a delegate and a method to issue the PerformStep() but the compiler tells me that the ToolStripProgressBar does not contain a definition for Invoke.

How do I update the progress bar?

Thanks in advance,
Hal

cjard
April 4th, 2007, 04:22 AM
Use a BackgroundWorker, and update the progressbar from the worker's progresschanged event, which is UI thread safe

If youre on 1.1 .net and dont have a BGW, you can get one by googling; its not part of the framework.
If youre on 1.0, upgrade

If you dont want to upgrade, you can call InvokeRequired on the form itself, and if it is needed, Invoke a method tha tupdates the progressbar. Pointless though, when background worker makes it so nice, and painless