I created a form which runs multiple background threads. I added another class which handles exceptions and errors if any. When the code runs, if an error occurs that should force the application to close can I just use Application.Exit()? Will that kill the background threads as well?
No, it will not. Application.Exit() will simply force the windows message pump to post a Quit message, which will terminate your application's main thread. However, the process itself will continue to run until the background threads complete.
Update: as commenters have correctly pointed out, if your thread's IsBackground property is set to True, terminating the main thread via Application.Exit() will shut down the process.
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