Exception thrown in worker

Nov 3, 2009 at 7:39 PM

Hi

In WorkItem.cs the worker catches an exception thrown by the function. I see there a comment: // Save the exception so we can rethrow it later.

When is the exception re-thrown?

I really need the exceptions re-thrown into the parent code.

 

Radu

Nov 3, 2009 at 9:58 PM

will this do?

 

     [Test]
        public void Exception()
        {
            var smartThreadPool = new SmartThreadPool();
            var result = smartThreadPool.QueueWorkItem(MethodThatThrows);
            Thread.Sleep(1000);

            if (result.Exception != null)
            {
                throw (Exception) result.Exception ;
            }
        }

        public void MethodThatThrows()
        {
            throw new Exception("hello");
        }