Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SetTimer Priority

Posted on 2001-07-17
11
Medium Priority
?
744 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 150 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

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 …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

730 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