I am aware of how unhanded exceptions are processed when using Task
s, only throwing an unhandled in the finalizer if user code hasn't 'observed' it yet.
I am also aware of how an unhandled exception in an async thread (e.g. Action.BeginInvoke()
) is caught and re-thrown on the joining call (e.g. Action.EndInvoke()
).
What I don't understand though is how this doesn't crash the process?
static void Main(string[] args)
{
var timer = new System.Timers.Timer() {Interval = 100};
timer.Elapsed += (o, e) => { throw new Exception(); };
timer.Start();
Console.ReadKey( true );
}
From the .NET 4.0 documentation:
In the .NET Framework version 2.0 and earlier, the Timer component catches and suppresses all exceptions thrown by event handlers for the Elapsed event. This behavior is subject to change in future releases of the .NET Framework.
http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx
There is no statement yet claiming that this behavior has actually changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With