Re: unable to break out of runloop because timers are fired and then the loop waits
Re: unable to break out of runloop because timers are fired and then the loop waits
- Subject: Re: unable to break out of runloop because timers are fired and then the loop waits
- From: Jason Bobier <email@hidden>
- Date: Wed, 24 Sep 2008 16:35:58 -0400
Thanks Nick. I'm trying to avoid polling tho (since that is the whole
point of runloops and mach ports).
Jason
On Sep 24, 2008, at 3:38 PM, Nick Zitzmann wrote:
On Sep 24, 2008, at 1:15 PM, Jason Bobier wrote:
Hey folks, I have a runloop on a thread that looks like this:
while (! _cancelled) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[runloop runMode:NSDefaultRunLoopMode beforeDate:[NSDate
distantFuture]];
[pool release];
}
And I put a timer in the loop that sets _cancelled to true, the
runloop never stops. What's the proper way to do this?
Don't run it until the distant future; that'll cause the call to
block until some time in 400X, by which time you probably won't be
using your current Mac anymore. :) Instead, you should run shorter
intervals (like a second from now), and if you need NSEvents to
trigger during the time, then you should probably use -
[NSApplication nextEventMatchingMask:...] instead with dequeueing.
That method also runs the specified run loop.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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