• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 775
  • Last Modified:

SetTimer Priority

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
win32
Asked:
win32
  • 3
  • 3
  • 3
  • +2
1 Solution
 
_ovCommented:
Hmmm... You can move it to the separate thread and set priority for it.
0
 
jhanceCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
win32Author Commented:
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
 
_ovCommented:
AFAIR WM_PAINT is a low-priority message too. Could you describe your problem in more detail?
0
 
win32Author Commented:
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
 
_ovCommented:
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
 
peterchen092700Commented:
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
 
peterchen092700Commented:
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
 
win32Author Commented:
My painting is not in the Timer, but the timer makes some changes in some variables and call RePaint();

CB.
0
 
peterchen092700Commented:
what is repaint?? You should just call InvalidateRect to invalidate theregions that need repainting.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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