I have a background thread in my application. When one of the threads receives an exception that is not handled, all CLR outputs.
Is this normal behavior, or is it a bug in the CLR?
I expect the thread to exit, but the CLR will continue to work.
.NET - , . , , , . , , , . .
AppDomain.CurrentDomain.UnhandledException, . - try...catch. , , . :
AppDomain.CurrentDomain.UnhandledException
try...catch
void MyThreadProc() { try { // ... } catch { // handle all exceptions // This is a BAD idea } }
, , .
, , 1.1. , . , . .. , , , . , , .. , , , .
, , question .
This is normal CLR behavior from version 2.0. Here is the MSDN post . To avoid completing the process, you can use something like this
<legacyUnhandledExceptionPolicy enabled="1"/>
which is impractical.
This is normal behavior. You might want to catch an exception to prevent the application from exiting.