Re: Stopping a NSRunLoop
Re: Stopping a NSRunLoop
- Subject: Re: Stopping a NSRunLoop
- From: "Shawn Erickson" <email@hidden>
- Date: Tue, 23 May 2006 12:17:25 -0700
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