Can the Backgroundworker work when it reaches the "... Completed" event handler

as described in the title. My magician does his job ... finishes the first part and calls ... the completed event handler. May I say here that my background worker is working with other work by doing DoWork - = OldJob DoWork + = NewJob

and DoWorkCompleted - = OldJobCompleted DoWorkCompleted + = NewJobCompleted

Is it possible?

+2


a source to share


2 answers


Yes, you can restart it after it finishes. And you can connect another DoWork first.

But you shouldn't.



The ThreadPool runs BGW, so there is no need to reuse Thread. So avoid clutter and just create separate background workers for different tasks.

+2


a source


I haven't tried it before, but I think it will work. Wouldn't you need to change your event handler for ProgressChanged and RunWorkerCompleted too?



I think it would be much easier to just create two background workers instead. Or, if the jobs are very similar, you can parameterize the existing background worker to be able to do both.

+1


a source







All Articles