Link to home
Start Free TrialLog in
Avatar of AlexFM
AlexFM

asked on

WM_TIMER message delay

WM_TIMER message handler in my program is called with significant delay - about 100-200 ms. Usually it's precision is 20-30 ms. For example, if I use

SetTimer(TIMER_ID, 1000, NULL);       // in CWnd-deriver class

OnTimer function may be called with 1100-1200 ms intervals. What may be a reason for this? This program worked number of years without problems.
Avatar of AlexFM
AlexFM

ASKER

Additional information:
I made small MFC test program which prints current time from WM_TIMER message handler. It works OK. When it runs together with the program which has timer delay, it works also. So, some changes made in the program give this result. What is a reason - too large program, long message map, something else?
I can replace WM_TIMER with multimedia timer, but it is interesting why this happens.
I haven't noticed that problem before, but, what happens if you use non-MFC SetTimer function?
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
More exactly:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.

But to get delays of more than 1 sec, you should have a significantly amount of high-priority messages in the queue (which seems unlikely to occur).
Avatar of AlexFM

ASKER

mokule's comment gives me right direction, so he gets these points.