Re: handling idle events
Re: handling idle events
- Subject: Re: handling idle events
- From: "Michael Ash" <email@hidden>
- Date: Wed, 6 Aug 2008 18:10:56 -0400
On Tue, Aug 5, 2008 at 10:16 PM, Jim Crafton <email@hidden> wrote:
> Is there a way to handle idle time in an NSApplication? In Win32 or
> Carbon, since you manually write the actual while loop that processes
> the events, this is pretty easy to do. Is there anything like this in
> Cocoa? I've got some objects whose state (possibly) needs to be
> updated, and I was planning on handling this in the "idle" handler.
>
> My other idea, if this is not possible, would be to simply have a
> timer that fires off every 0.5 seconds or so.
In addition to the solutions already proposed, there are some other
techniques available depending on exactly what you need:
1) If you need to check on your status at every pass through the event
loop, and your object is tied to a particular window, you can use
NSWindowDidUpdateNotification.
2) If as above but your object is not tied to a particular window,
there is NSApplicationDidUpdateNotification.
3) And lastly if you want to check at every pass through the runloop
(note: not the same as the event loop, although they are closely
related, and an application's main thread will be running both), or
otherwise need more control over when your code is run,
CFRunLoopObserver will let you register callbacks for various stages
of runloop processing.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden