Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer Problem

Status
Not open for further replies.

paulyc

Programmer
May 13, 2003
4
US
I am having a problem using the OnTimer class in my program. While the timer is running, none of the buttons that are on my GUI respond in a timely fashion. I am gussing this is because the timer is taking conrtol on the CPU, and the button click only reponds after the timer has completed its iteration. Is there a way to give the button clicks higher priority over the timer? I am trying to make it so the user can click on a button and not think that the program is locked up.
 
OnTimer is the usual name for the handler method of the WM_TIMER message associated with timers. It is a message just like button click notifications. This means they are serialized -- same priority, first come first served.

What's probably happening is either:

a) You have set the timer period way too short, causing tons of WM_TIMER messages to flood your message pump.

b) You are doing something in the OnTimer method that is taking a long time. While any message, including WM_TIMER, is in process by a message handler, no other messages can get through (unless you reenter the message pump, like when you call DoModal on a dialog).

It might be a combination of the two. Try reducing the timer period. Also, think about making your program multi-threaded, and move what you're doing in the OnTimer handler to this other thread. Then you can make that thread lower priority if you wish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top