Throwing exceptions in callback method for Timers

Viewed 15683

I was unable to find an answer to this question anywhere...

What happens with the exceptions thrown in the callback method for System.Threading.Timer, (or in the event handler for System.Timers.Timer). Is the exception propagated to the thread on which the timer was created or is the exception lost?

What are the side-effects of throwing an exception within the timer's callback functions?

What would be the right way to signalize to the timer's creation thread that the exception in the worker thread (callback method) has been thrown?

Thanks for your time.

4 Answers

From my humble test under windows 10 framework 4.6, the thread used by the SystemTimers.Timer elapsed event will not propagate the unhandled exception. I needed to fire a event to the main thread to notify the unhandled exception happened.

Related