Re: NSTimer in main NSRunLoop v. InstallEventLoopTimer
Re: NSTimer in main NSRunLoop v. InstallEventLoopTimer
- Subject: Re: NSTimer in main NSRunLoop v. InstallEventLoopTimer
- From: Ken Thomases <email@hidden>
- Date: Wed, 10 Sep 2008 10:04:42 -0500
On Sep 10, 2008, at 4:19 AM, Wesley Smith wrote:
I'm trying to figure out how I can have my app run a timer that never
suspends when the user interacts with menus and the like.
You can use -[NSRunLoop addTimer:forMode:] to schedule the timer on
additional run-loop modes. You might want to use
NSEventTrackingRunLoopMode, for example.
Whether this is a good idea or not is another question. Remember, no
matter what mode(s) a timer is scheduled in, there's no guarantee that
it will fire at any given rate. At any given moment, the application
may not be idle in its event loop -- it might be doing processing or
handling some other event. Also, depending on what you're doing in
response to the timer firing, it might not be appropriate during menu
tracking, etc. So, depending on what you're trying to achieve, you
may be asking the wrong question.
Cheers,
Ken
_______________________________________________
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