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.
LVL 48
AlexFMAsked:
Who is Participating?
 
mokuleConnect With a Mentor Commented:
Maybe this is an answer

Remarks
The DispatchMessage Windows function sends a WM_TIMER message when no other messages are in the application's message queue.

0
 
AlexFMAuthor Commented:
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.
0
 
Jaime OlivaresSoftware ArchitectCommented:
I haven't noticed that problem before, but, what happens if you use non-MFC SetTimer function?
0
 
nonubikCommented:
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).
0
 
AlexFMAuthor Commented:
mokule's comment gives me right direction, so he gets these points.
0
All Courses

From novice to tech pro — start learning today.