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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does onidle work

Status
Not open for further replies.

sggaunt

Programmer
Jul 4, 2001
8,620
GB
I have an application which waits in an onidle function and checks 'time' against a preset value. so the action can take place at a preset time.
Sometimes this dosent work. I thought it might have somthing to do with the screen saver and set this to a long period to ensure it was not running.
But the program still seems to be waiting after the time set. Moving the mouse or a key press sets it going though.?

Steve.



 
If you are comparing to a pre-set time so something can occur after an interval, you could try TTimer. Even if you are looking for an absolute time, using TTimer should be more efficient and it seems to work, so subtract current time from pre-set time and set TTimer to the difference. (Hope I've not missed the point here as I've never used onidle!)
 
I use OnIdle in one of my programs. As I understand it, it is called once when there is nothing for the program to do.

When an event occurs, such a key press or mouse click the program will handle the event and when it has finished handling the event and there are no other events to process it calls the OnIdle routine once.

So using OnIdle does not seem suitable for your requirements. A TTimer as Dooda suggests should be appropriate.

Andrew
 
towerbase is correct. OnIdle is called just after the last event in the eventqueue has been processed to notify the application and operating system that the aplication doesn't have anything to do.
 
Thanks for that guys. The way I interperated the 'Help' on onidle routines was that they are called continuosly when an application is 'idle' i.e not proccessing any other events, I believe the Help says something about keeping onidle routines short this is why i made the above assumption.
If indeed it is only called once this would explain what I am seeing, I will have a go with your suggestion Dooda, though I have some concerns about the accuracy of a Timer over several hours, which is possible for this application.
Steve
 
When I had to handle this: I set up a timer for once a minute. Each tick it updates the time until activation (which is displayed in my case) and if that's zero the actual event is triggered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top