Solved

changing WM_TIMER priority

Posted on 1997-10-17
3
1,073 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now