views:

212

answers:

4

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?


A: 

You'll have to catch the exception inside the callee, otherwise you'll get a an ThreadException, i believe.

BeowulfOF
A: 

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. http://www.codinghorror.com/blog/archives/000216.html

Brian
+3  A: 

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.

John Leidegren
+1  A: 

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

Jakob Christensen