Does anyone know how System.Windows.Forms.Timer affects the host application and the system in general?

Does anyone know how it System.Windows.Forms.Timer

affects the host application and the system as a whole?

In a threaded background loop, on the one hand, there is a lot of CPU usage%, while a Timer

very high tick rate has no effect in Windows Task Manager.

Is the high tick rate timer delaying the Windows Message loop or?

+1


source to share


2 answers


Define "high speed timer" :).

The problem with timer components using WM_TIMER (e.g. Windows.Forms one) is manifold:



  • You won't be able to get more than 50ms resolution from it, ever.
  • If your system is under stress (like heavy redrawing, working on RDP links, etc.), you can receive WM_TIMER messages every 500ms or more, no matter how low you set the interval.
  • WM_TIMER messages are synthetic messages and may not be delivered to your application at all for long periods of time if the message queue is flooded with other messages.
  • If your timer method takes more than one timer interval to execute, the timer will "skip" the message; you won't get another WM_TIMER message until you return from the first one. In other words, you will never receive two WM_TIMER messages one after the other in sequence.
+3


source


All in all I haven't noticed a lot of negative references to using the timer component inside my application, they are much more efficient and better on resources than some of the other methods out there.

I find this "Timer Comparison" from Microsoft helps to compare these types of things as well.



But long and short that they don't seem to clutter too much.

+1


source







All Articles