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

gennady wexler adyler@winisp.net
Tue, 19 Oct 2004 09:43:48 -0700


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
>> 
>>  
>> 
>