Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1179
  • Last Modified:

changing WM_TIMER priority

How can i change message priority's in MFC, is it possible at all?
I don't know why, but WM_TIMER is a low priority message, the timer proc. is called after all other messages are handles.
I have tried already:
1) CWinApp::IsIdleMessage
2) SetWritableTmer as an alternative ( so stupid, the thread has to be in a wait/alertable stat - SleepEx )
3) timeSetEvent as an alternative - it's ok, but i would realy want to change that WM_TIMER priority - no semaphores needed + i already finished a whole lot of code writing, based on WM_TIMER...
thanx  :-o
0
shaig
Asked:
shaig
  • 2
1 Solution
 
shaigAuthor Commented:
Edited text of question
0
 
MelangeCommented:
The WM_TIMER message has never been guaranteed to be an exact accurate measurement of time. It is only a notification that at LEAST the required interval has passed. For example, if you have a timer for 1 second intervals and then decide to do a thread eating 5 second process you will NOT receive 5 different timer messages when you resume processing messages. You will only get 1.

The way WM_TIMER works is that when the interval has passed, Windows sets a flag in your message queue. When the last message is processed in your queue, Windows checks this flag and then decides that it should either send you a WM_TIMER or call your TimerProc (depends on how you used the SetTimer call).

If you truly need something that is near 100% accurate on time intervals, then you will need to use something else, preferably a second thread that does the time critical process.

0
 
shaigAuthor Commented:
The stuff about "eating cpu for 5 seconds..." is obvious, but why the hell is this message handled last?
Is there such a thing called a "message priority"?
Is the source code of the section you descried available anyware?
Since the timer event has to be processed by one praticular thread, another thread won't help because it will have to wait for the first one to have time for it anyway ( event's pass only when a thread is in that stupid alertable wait stat ).
Is there a way to signal  ( interrupt ) a thread without having it put to sleep ( or to SleepEx if to be exact ) ?
thank you very much for responding, sorry for beeing such a pian  in the butt, oh... and sorry for my poor english.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now