[Mono-dev] ThreadPool unhandled exceptions
Adar Wesley
adar.wesley at gmail.com
Wed Dec 23 18:05:18 EST 2009
Just verified that on MS .NET this has the following output:
About to throw an exception
UnhandledException !
Application Complete
Press any key to continue . . .
So it seems to me this is a bug in Mono implementation.
---
Adar Wesley
On Wed, Dec 23, 2009 at 9:27 PM, Thad Thompson <TThompson at nucsafe.com>wrote:
> Hi,
> I know this has been raised a few times in the past (bugs 332206,
> 334265, and 435127) but I've looked high and low for a workaround and
> just can't seem to find it. Is there any way to catch, trap, log, crash,
> or in any way be notified of an unhandled exception from a ThreadPool
> thread? My apologies in advance if I've overlooked something basic.
>
> Thanks,
> -Thad
>
>
> Example:
> ---------------------------------------------------------------------
> namespace MonoExceptions
> {
> class MainClass
> {
> public static void Main (string[] args)
> {
> try
> {
> AppDomain.CurrentDomain.UnhandledException += (a,b) =>
> { Console.WriteLine("UnhandledException !"); };
>
> System.Threading.ThreadPool.QueueUserWorkItem ( (a) =>
> {
> Console.WriteLine("About to throw an exception");
> throw new Exception("I'd really like to catch
> this");
> });
>
> System.Threading.Thread.Sleep(5000);
> Console.WriteLine("Application Complete");
> }
> catch(Exception ex)
> {
> Console.WriteLine("Caught exception in Main: " +
> ex.Message);
> }
> }
> }
> }
> ---------------------------------------------------------------------
> Output:
> About to throw an exception
> Application Complete
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20091224/f4dbb236/attachment.html
More information about the Mono-devel-list
mailing list