Let's say I have a Timer control with interval set to 20ms. Inside this control I am doing some operation that takes 100ms to complete. So once it is doing that operation, will Timer control execute again without waiting for that operation to finish? Or until that operation is not finished, Timer will not execute again?
EDIT
I am using System.Timers.Timer() in a separate thread in console application. I have edited my question after discussing with Andrew below.
System.Timers.Timer
For more details on timer types, please refer the link http://msdn.microsoft.com/en-us/magazine/cc164015.aspx
Note : The previous example was written assuming that the timer instance was System.Windows.Forms.Timer but clarifications from the author indicated that System.Timers.Timer() instance is used.
System.Timers.Timer
both runs and raises events on a 'random', thread pool thread. The callbacks and the timer ticks will run concurrently, meaning you would have overlapping execution of these events in your situation where the interval is less than the time the method takes to terminate.Even though this behavior is different from that which I posted about below, you still don't want to do this. The result will be that the thread pool will eventually become exhausted. It is also probably not your desired functionality.
A solution would be to code it such that concurrent execution is not possible.
Previous Answer
This was the old answer I posted when I thought you were speaking of the Timer in System.Windows.Forms and using it in a Windows Forms program. Because that is not the case, the information below does not apply to you. But I leave it here in case it helps someone else.
Because the Timer control inside the System.Windows.Forms namespace runs on the UI thread, as does its callback, your tick events will pile up, waiting for currently executing operations to complete. You UI will also be locked in the duration.
Therefore, you do not want to do this. Your program will lock up.
The System.Windows.Forms.Timer is single-threaded and only has a resolution of 55ms.But since it's single-threaded the Tick events shouldn't step on each other.
http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx
In a single threaded application, ticks will be queued if the execution could not happen. It also has a resolution of ~55ms
See http://msdn.microsoft.com/en-us/library/xdh6857z.aspx
See How to prevent System.Timers.Timer from queuing for execution on a thread pool?