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

System idle time

Status
Not open for further replies.

BeanDog

Programmer
Jul 15, 2000
60
0
0
US
Is there a way I can find out how long the system has been idle? I need a process to run in the background while the system is idle. An example would be FindFast. How do they index your hard drive only when the system is able, or how does windows start screen savers when the system has been idle for a period of time?



~BenDilts( void )
 
It is possible to set a timer to signal you when
no action (i.e. no keyboard input and no mouse move)
has happened in a given time , and to re-set it each time
such input arrives. That is the screen-saver way.
Another question is to "know" when the system is idle.
You can set the priority of the background task to the lowest, so it will be given CPU time only when no other task is waiting to CPU. There is no need to "know" when
the system is idle for that purpose.
If your application wants to perform some job on the background, you can use the WM_IDLE (or something like that)
message sent when no other messages are in the queue (note, however, this does not mean that some thread of the process is not doing CPU-crunching without getting window messages !

It depends what you want to acheive, so use one or more of the above methods.
Good Luck ======
SeekerOfKnowledge
======
 
Use either SetTimer for coarse time-measure (up to 55 msesc i think) or something like SetWaitableTimer for more
precise and thread-oriented approach ======
SeekerOfKnowledge
======
 
You may also want to check our the SetPriorityClass API function. If you set the priority class of your process/thread as IDLE_PRIORITY_CLASS, it will only run when the system is idle.
 
How to check if the system is idle is not(no mouse movements and no keystrokes)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top