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

Mariano Alarcon marianoa@itcsoluciones.com
Tue, 19 Oct 2004 14:47:12 -0300


I see the same results (exception not thrown) in my gentoo with mono 
1.0. But when I take the mcs binary and run it on my winxp with ms.net 
1.1 the exception is caught by the main thread. I don't know what the 
correct behavior should be, but there is certainly something different 
between the two implementations.

gennady wexler wrote:

>how about mono? can you see it not working when run under mono? including
>1.1.1? then we need to bug this. would be nice if someone on monodev can
>comment on this. is this an unsupported scenario?
>
>
>On 10/19/04 5:09 AM, "Mariano Alarcon" <marianoa@itcsoluciones.com> wrote:
>
>  
>
>>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@lists.ximian.com
>>>http://lists.ximian.com/mailman/listinfo/mono-list
>>>
>>> 
>>>
>>>      
>>>
>
>
>
>  
>

-- 
Mariano Alarcón
ITC Soluciones