Solved

SetTimer Priority

Posted on 2001-07-17
11
717 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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