System.timers.timer hung or hangs or hanged

While researching for better techniques during development of time attendance system with door access control module, I found this topic interesting to look into.
  1. System.timers.timer will not run or will not continue to run if there is exception. In this case, the timer will stop prematurely.

    --> To deal with this, just implement exception catching within the timer process.

  2. System.timers.timer may hang if there is a deadlock. A very common type of deadlock will arise when the time taken to complete the timer process is longer than the interval time. This is also known as reentrancy. When such happens, the next timer process will start while previous timer process is still running, this may potential create a deadlock or race condition situation.

    This will also cause the application to hang.

    --> To deal with this, implement the following two things:

    1. Stop the timer while timer process is being executed, restart the timer when the process is completed. For this implementation, do rely on invoking the 'enable' property directly. This is because it is not thread-safe, you have to invoke the 'stop' and 'start' methods.
    2. Implement custom thread-concurrency on top of invoking 'stop' and 'start' methods.

To further understand this, download the sample code (VB.NET Visual Studio 2008 SP1)