Events and Background worker

S

sjoshi

I have a class that sends event notifications during a time consuming
operation. In the UIclass for the form, I have subscribed to that event
to paint the progress bar in this

_backupMgr_PercentCompleted(object sender, JobCompletedEventArgs e)
{

}

If I now use a background worker now in the UI, how would I handle the
paint in do_work method ?

thanks
Sunit
 
G

Guest

Can you be more specific?

You can't perform any interaction with a form within the DoWork event
handler of BackgroundWorker as it's in a different thread than the form. The
progress and completed events of the BackgroundWorker can interact directly
with the form as they are guaranteed to execute on the thread that
instantiated the BackgroundWorker object (assumes the same thread that
instantiated the Form object).

If you're doing custom painting that has to be done in the OnPaint method or
in a Paint event handler.
 
S

sjoshi

Peter said:
Can you be more specific?

You can't perform any interaction with a form within the DoWork event
handler of BackgroundWorker as it's in a different thread than the form. The
progress and completed events of the BackgroundWorker can interact directly
with the form as they are guaranteed to execute on the thread that
instantiated the BackgroundWorker object (assumes the same thread that
instantiated the Form object).

If you're doing custom painting that has to be done in the OnPaint method or
in a Paint event handler.

Thanks...I understand that. The thing I'm confused about is how to
communicate information from the event that I have subscribed to of the
_backupMgr class, to the progress event of the BackgroundWorker class.

Sunit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top