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

gennady wexler adyler at winisp.net
Tue Oct 19 03:58:26 EDT 2004

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

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?)
                        WaitCallback(_ThreadProc), null);

                // uncomment this to thrown exception 2 (as expected)
                // new Thread(new ThreadStart(_ThreadProc2)).Start();


        private static void _ThreadProc(Object state) {
                throw new Exception("exception 1");

        private static void _ThreadProc2() {
                throw new Exception("exception 2");

More information about the Mono-devel-list mailing list