Background:
Our product has one instance of dedicated application (Win32 Delphi) for each device connected to our system. Recently we have a huge project where over 100 devices were connected, so our control application started 140-160 Win32 applications. Every application has its timer, and we have seen that ALL timers tick slower, when mouse cursor points to desktop.
Problem:
After experimenting i found out, that it is not a timer problem, but the speed of message pump processing.
Tests:
I have created test application, that has 3 different timers: simple Delphi TTimer (actually SetTimer/KillTimer inside), QueueTimer using messages for calling callback routines, and QueueTimer calling direct callback routines. Test app has also 3 labels to show time when timer tick happened. All timers tick every 20 mS, and every 10 ticks (=200 mS) test app refreshes label for particular timer.
Problems start to happen when I start more than 110 applications (minimized). After restoring one app from minimized state, i can see, that if mouse cursor points to ANY window (test app window, task manager, Notepad, even windows taskbar) - then all timers tick as expected (surely TTimer isn't that precise as QueueTimer, but still in acceptable range). But as soon as mouse cursor points to windows desktop (including any shortcut in desktop) - then i see, than ticks from timers, that use messages, come much slower as before. Only QueueTimer, that uses direct callbacks, continues to tick with same speed.
Question:
Is there any way to disable such "feature" of Windows?
Tested and reproduced on:
- W7 + Intel Xeon (4 cores) + NVidia (256MB RAM) + 16GB RAM,
- W10 + Intel Xeon (4 cores) + NVidia (256MB RAM) + 16GB RAM,
- W2016 Server + Intel 16 cores + 64GB RAM + AMD Radeon (1 GB RAM).
All windows visual effects (like mouse pointer shadow etc.) are off, it happens as well with desktop solid color background.
I have really no ideas how to change this windows behaviour. I tried to change windows desktop heap size without any effect.
If some additional information is needed (code samples, compiled apps) - pls let me know.