Re: Idle time
Re: Idle time
- Subject: Re: Idle time
- From: Jens Bauer <email@hidden>
- Date: Thu, 10 Jan 2002 15:11:49 +0100
Hi Brian,
On Wed, 9 Jan, 2002, Brian France <email@hidden> wrote:
>
I want to start a task after a period of idle time. When the
>
application is idle (no user interaction). The machine does not need
>
to be idle, just the my application. Can and how can this be
>
calculated?
There are several ways of doing this, since you are designing the
application yourself.
A simple method is to use NSTimer, and then set flags in your code where
it goes busy.
1: Create a scope counter, set it to 0.
2: Set up the NSTimer
3: Start the automatic operations. Each operation should be shielded with
"BeginOperation" and "EndOperation".
BeginOperation does this:
Disable the NSTimer
Increment the scope counter
EndOperation does this:
Decrement the scope counter
If the scope counter goes zero, enable the NSTimer
For an example on how to use NSTimer, you can look in the /Developer/
Examples/AppKit/CircleView/ project.
Hope this gets you started. :)
Love,
Jens
--
Jens Bauer, Faster Software.
References: | |
| >Idle time (From: Brian France <email@hidden>) |