I was working on a project at a client site almost a month ago, and ran into an annoying issue with the System.Timers.Timer class. The following code snippet should demonstrate the issue clearly:
1 2 3 4 5 6 7 8 9 10
If you go ahead an run this code you can quickly take note that the program does not die. It will continually output the message “About to throw unhandled exception” until you press a key and hit enter.
If , however, you make use of the System.Threading.Timer class :
1 2 3 4 5 6 7 8 9
The program will die a horrible death (as expected) and you could deal with the error accordingly using a global error handler. Of course, using a global error handler is only useful if the unhandled error can be caught in the first place in the case of the System.Timers.Timer this is not the case:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Just a quick bit of information in case you ever run into this problem.