Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Timer controls run faster while the window is minimized

It's actually a noticeable difference that I've seen but cannot explain. These timers have intervals set to 1ms (the lowest available), but while it's minimized, it seems to tick faster? Could anyone explain this phenomenon to me? And if possible, explain how to reproduce the effect while the window is maximized?

like image 642
Gio Borje Avatar asked Oct 17 '25 17:10

Gio Borje


1 Answers

Is this a Forms.Timer?

I doubt it is running faster, more likely that the Timer firing event is being handled in a more timely manner. Whilst minimised there will presumably be less messages handled by the Form windows's message pump, which could account for a larger time slice to handle the Timer messages. There is also the isue of the minimum Timer resolution.

If applicable, try using one of the other Timer types, such as System.Timers

The Windows Forms Timer component is single-threaded, and is limited to an accuracy of 55 milliseconds. If you require a multithreaded timer with greater accuracy, use the Timer class in the System.Timers namespace.

Ref.

like image 111
Mitch Wheat Avatar answered Oct 19 '25 07:10

Mitch Wheat