Solved

changing WM_TIMER priority

Posted on 1997-10-17
3
1,107 Views
Last Modified: 2013-11-20
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
Comment
Question by:shaig
  • 2
3 Comments
 
LVL 3

Author Comment

by:shaig
ID: 1308270
Edited text of question
0
 
LVL 3

Accepted Solution

by:
Melange earned 100 total points
ID: 1308271
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
 
LVL 3

Author Comment

by:shaig
ID: 1308272
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question