Solved

SetTimer Priority

Posted on 2001-07-17
11
702 Views
Last Modified: 2013-12-03
Hi

How do you set a priority for a timer, I want to make an IDLE timer, but is'nt there a function like

.SetPriority(LOW);

CB.
0
Comment
Question by:win32
  • 3
  • 3
  • 3
  • +2
11 Comments
 

Expert Comment

by:_ov
ID: 6290152
Hmmm... You can move it to the separate thread and set priority for it.
0
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 6290264
A timer doesn't "run" like a thread.  It's set.  When it happens, Windows will send a message.  There is no priority for the timer itself.  The place for priority is in the thread that gets the timer message (WM_TIMER).  Set that thread to be a low priority.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 6291188
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:win32
ID: 6292543
But I am having some prublems, When my timer starts, my Redraw functions does'nt seem to work. eg. I click a button, but the button is not redrawn.
CB.
0
 

Expert Comment

by:_ov
ID: 6292595
AFAIR WM_PAINT is a low-priority message too. Could you describe your problem in more detail?
0
 

Author Comment

by:win32
ID: 6293761
Only problem is sometimes a bit of flicker, because of the Paint() and Timer() running "at the same thread" at same time!

If a timer is running, can you reset it ?.. I mean, if i set the timer to 2 sec, and 1 second has elapsed, and for some reson I want to reset the timer, so it starts from the time 0 sec..

How can I do that ?, I mean I can't realy kill the timer it does'nt work, the timer will not be killed untill the next event.

Or can I kill the timer in a way, so I won't have to wait for the next event ?
0
 

Expert Comment

by:_ov
ID: 6293851
Of course you can kill the timer.

You can use this pair: KillTimer() SetTimer() even if you have no any timer at this time.

So, you can use something like this:
void ResetTimer(HWND hWnd, int id, int elapse) {
  KillTimer(hWnd, id);
  SetTimer(hWnd, id, elapse, NULL);
}
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6294912
a) can you explain your problem? I'd like to doubt that two messages are handled at the same time in the same thread...

What windows does is: When Message Queue is empty, it sends WM_PAINT messages to windows with invalid regions. Only after that, pending WM_TIMER messages are sent.

Is all your painting in the WM_PAINT handler, or are you doing some of the painting in WM_TIMER? (you shouldn't....)


Peter
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6294926
BTW... your WM_TIMER handler can also set a flag, that is processed & cleared in the Idle handler

VC++ frameworks (MFC, ATL) provide OnIdle handlers somewhere, or if you are in raw Win32, you might need to adjust your message loop for this.

Peter
0
 

Author Comment

by:win32
ID: 6297343
My painting is not in the Timer, but the timer makes some changes in some variables and call RePaint();

CB.
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6297896
what is repaint?? You should just call InvalidateRect to invalidate theregions that need repainting.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

830 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