I hav开发者_StackOverflow社区e an application that contains two forms. I want to implement a BackgroundWorker for the Child Form so that when it is launched and a user selects a button the operations will be executed on the BackgroundWorker, the Child Form will be hidden, the BackgroundWorker will report to the Parent Form so that a progress bar can be updated, and the Parent Form is still active so a user can still use it while the BackgroundWorker is running.
Any help with this would be greatly appreciated. I just need someone to give me a starting point and help point me in the right direction.
I would create an event in your child form that the parent form subscribes to. In your child form whenever the ProgressChanged event is fired from your background worker you would basically fire the event that your child form exposes to the parent form.
You could also expose your BackgroundWorker in your child form to the parent form so that it could just subscribe to the ProgressChanged event.
Edit:
Subscribing to an event:
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
精彩评论