Or another facet to the questions is: should I be handling the possibility the form is closed when coding a background worker?
I have, for example, code that does an SQL query (which is not cancellable) in a background worker then when complete "boldifies" dates in a calendar control to match the dates returned from the query.
I'm curious what the background worker is designed to do in such a situation?
- not fire the RunWorkerComplete
event?
- ignore calls to the dialog in the RunWorkerComplete
function call because it's not a window any more?
If the form you are closing is the main(in other words the only) form then the background worker thread will automatically close with the closing of application.
If it is not the main form then the background thread will keep on running. In this case you should manually abort the background thread with the closing of your form
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With