Reputation: 8704
I need to catch error during DoWork
and if the error is of some type- re-run the same BachgroundWorker. Already tried to cancel it and call RunWorkerAsync()
during Completed
event, but no luck(exception appears saying that my backgroundworker object was canceled).
Upvotes: 1
Views: 1524
Reputation: 273209
I would guess that the Bgw remains in the Error/Canceled state until the Completed event has finished.
A few options:
A Bgw itself is not expensive so there is little point in reusing a specific instance. The threads come from the ThreadPool.
Upvotes: 3