Re: Stopping a NSRunLoop
Re: Stopping a NSRunLoop
- Subject: Re: Stopping a NSRunLoop
- From: Andrei Tchijov <email@hidden>
- Date: Tue, 23 May 2006 15:22:23 -0400
Do not bother with getCFRunLoop/CFRunLoopStop. It does not work.
Your own loop with terminal condition and runMode:beforeDate: the
only way to go (this is actually the way promoted in Apple doc about
Run Loop)
On May 23, 2006, at 3:17 PM, Shawn Erickson wrote:
On 5/23/06, Rob Crawford <email@hidden> wrote:
How do you stop a NSRunLoop that is running inside a spawned off
thread with NSThread detachNewThreadSelector? I have a the run loop
for a timer to get fired once the timer fires, I want the NSRunLoop
to stop and free up the thread? In the Timer I have tried [NSThread
exit] but I seem to have threads still hanging around?
How are you running this runloop? Consider using -[NSRunLoop
runUntilDate:] or -[NSRunLoop runMode:beforeDate:] and wrapping it
with a loop that checks if the runloop should stop.
I believe you could also use -[NSRunLoop getCFRunLoop] to get the
CFRunLoop and then call CFRunLoopStop() on it (never tried it myself).
Also question the need for using the runloop at all for a simple
timer. You maybe could use -[NSThread sleepUntilDate:] to put your
secondary thread to sleep until some point in the future, much like a
timer callback via a runloop. Not sure of your exact needs.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden