[Mono-devel-list] Re: [Mono-list] exceptions are not thrown from ThreadPool'ed thread objects?

Mariano Alarcon marianoa at itcsoluciones.com
Tue Oct 19 08:09:59 EDT 2004


It works as expected with ms.net without having to uncomment anything.

gennady wexler wrote:

>has anyone noticed this problem? that is if you have a ThreadPool'ed thread
>object created, any exception thrown inside of that thread will not be
>rethrown up at all. I ran into this accidentally while developing some
>performance code..
>
>here's an example, could someone please try this with .net compiler/runtime?
>
>if you just compile and run it, the exception in _ThreadProc does not get
>thrown.
>
>now, if you uncomment regular thread definition below "ThreadPool" - you
>will get "exception 2" get thrown.
>
>any ideas? is this expected? I hope not...
>
>using System;
>using System.Threading;
>
>public class main {
>        static void Main() {
>                // this will not throw exception 1 (seems to be a bug?)
>                ThreadPool.UnsafeQueueUserWorkItem(new
>                        WaitCallback(_ThreadProc), null);
>
>                // uncomment this to thrown exception 2 (as expected)
>                // new Thread(new ThreadStart(_ThreadProc2)).Start();
>
>                Thread.Sleep(90000);
>        }
>
>        private static void _ThreadProc(Object state) {
>                throw new Exception("exception 1");
>        }
>
>        private static void _ThreadProc2() {
>                throw new Exception("exception 2");
>        }
>}
>
>
>_______________________________________________
>Mono-list maillist  -  Mono-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-list
>
>  
>




More information about the Mono-devel-list mailing list