Peter,
There are 3 different types if timers in the .NET framework:
System.Timers.Timer, System.Threading.Timer and System.Windows.Forms.Timer.
The events for the first two are executed in a separate worker thread so
basically they won't block the UI, for example. The first one, though, can
be synchronized with a control class thus, have its event handler marshaled
for execution to the main UI thread so it can block the UI.
The latter uses windows timers that send message to the application message
queue. These timer messages are very low priority messages (probably there
only one message with lower priority, so these timers might be inaccurate
and shouldn't block the normal flow of the application's windows messages.
When the processing of the timer tick begins, though, it will execute in the
UI thread thus make the application not responsive for the time of
processing.
As you can see the only think that can slowdown the application is the type
of processing that you do when the timer tick fires.
If you are planning to run lengthy operation you should probably consider
using System.Threading.Timer, but you need to make sure that you sync access
to shared data with other threads.
If you don't want to bother with thread sync and the process of tick event
is quick and the accuracy of the timer is not important maybe
System.Windows.Forms.Timer is better choice.
If the timer needs to be accurate and you don't want bother ensuring thread
safety you should probably consider System.Timers.Timer using the form (or
some other control) as SynchronizingObject.
This doesn't probably answer directly your question, but without more
detailed information on what timer do you use, what do you do in the event
handler, what do you mean by "slowing down the application" it is kind of
difficult to give more specific answer.
HTH
Stoitcho Goutsev (100) [C# MVP]
Peter Rilling said:
What do you mean "slows down everything"? How do you know it is slowing
your program? What do you notice?
Also, what timer are you using? If I remember, there are like two classes
named Timer.