Question

Related:


If a method throws an exceptions that is called by the ThreadPool.QueueUserWorkItem method where will the exception be thrown? or will it just be eaten?

I mean it will never be thrown on the calling thread right?


Was it helpful?

Solution

NO, the exception will never propagate to another thread. It will eventually crash the thread, and be caught by the runtime. At this point the runtime raises the AppDomain.UnhandledException event where the exception can be observed.

You can read more about this here.

OTHER TIPS

The exception will crash your application if is not caught inside your thread callback (except for ThreadAbortException and AppDomainUnloadedException that are swallowed). Note that in .NET 1.1 all exceptions were swallowed. The behavior was changed in .NET 2.0.

I found this link: http://msdn.microsoft.com/en-us/library/ms228965.aspx

Unhandled exceptions will bring down the app in .Net 2.0 or higher. The exception from QUWI code will not be caught or transferred to another thread.

See e.g. https://blog.codinghorror.com/improved-unhandled-exception-behavior-in-net-20/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top