Well I'll admit that I'd never heard of a BackgroundWorker, however after looking up the class I'm not convinced you need to use one. That being said the MSDN library states....
"You must be careful not to manipulate any user-interface objects in your DoWork event handler. Instead, communicate to the user interface through the ProgressChanged and RunWorkerCompleted events."
This would seem to indicate you need to use the ProgressChanged event.
Basically, the way that control works is you impliment three event handlers for three basic events the background worker raises, DoWork, ProgressChanged, and RunWorkerCompleted and communicate with the controls in the main thread from those event handlers.
There are other methods you can use involving delegates, but if you are able to handle the updates in the ProgressChanged event handler, then you won't need to use them.
Edit:
And cags beat me to the punch! I have used the background worker and it made a lot of really complicated stuff that I was doing in 1.1 very easy when I ported the code to 2.0. It won't work in all situations, but when you can use it, it makes everything a lot easier.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.