Re: Running a timer on a separate thread
Re: Running a timer on a separate thread
- Subject: Re: Running a timer on a separate thread
- From: Ken Thomases <email@hidden>
- Date: Fri, 20 Feb 2009 18:13:56 -0600
On Feb 20, 2009, at 8:23 AM, Jean-Daniel Dupas wrote:
Le 20 févr. 09 à 01:42, Ken Thomases a écrit :
On Feb 19, 2009, at 6:26 PM, Dave DeLong wrote:
but we can't figure out how to keep the thread alive and open so
that the timer can fire. At first, the thread would die right
after scheduling the timer on the thread's runloop.
Right. A run loop exits if it has no proper run loop sources. A
timer is not sufficient. So, one strategy is to add a bogus input
source. Creating an instance of NSPort and adding it to the run
loop is the typical solution.
Are you sure ?
Hmm. I _had_ been sure, but a review of the docs shows I was wrong.
Thanks for the correction.
I guess I got my wires crossed with respect to all of the warnings
that "A timer is not considered an input source and may fire multiple
times while waiting for [one of the run methods] to return".
So, I guess the OP was scheduling the timer and then just letting
execution fall off the end of the thread's method, which causes the
thread to exit. He needed to explicitly run the run loop.
Regards,
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