Solved

SetTimer Priority

Posted on 2001-07-17
11
692 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

809 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