Detect when a thread/tick has crashed in a windows service
Posted on 2012-08-29
I have a windows service written in asp.net 2 (VB.NET).
When the service starts, a timer is created and everytime the timer ticks a block of code is executed.
This code block accesses a database, incase there is a problem the SQL is executed within a try catch block and any error that occurs is written to a text file.
The issue I'm having is that when this happens, even though the sql statement is in a try catch block, the tick/thread crashes.
this is a problem because for every tick, I disable the timer, then re-enable it when the code block has executed.
So, I need to know is there a way to detect if the tick/thread has crashed or if an error handler can be added?
I would like to avoid having one big try catch statement.