Re: Challenge: Block Main Thread while Work is done, with Timeout
Re: Challenge: Block Main Thread while Work is done, with Timeout
- Subject: Re: Challenge: Block Main Thread while Work is done, with Timeout
- From: Charles Srstka <email@hidden>
- Date: Fri, 24 Jul 2009 17:20:25 -0500
On Jul 24, 2009, at 5:10 PM, Dave Keck wrote:
The notifications don't cross threads; they are delivered in the
thread
where they are posted.
Yes, I understand that. There must be some quirk that allows it to
work
when doing an NSTask
Just a tidbit - I don't think there's any quirks involved. The general
idea is this: NSTask creates a run loop source on the main thread, and
spawns a second thread to watch the process for termination. When the
process terminates, the secondary thread signals the main thread's run
loop (via CFRunLoopSourceSignal()), and the run loop source's callback
then executes on the main thread, which issues the notification. On
10.5+, this can be done trivially using kqueue and CFFileDescriptor.
You could probably also notify the main thread by using -
performSelectorOnMainThread:withObject:waitUntilDone: to execute
NSNotificationCenter's postNotification: method.
Charles
_______________________________________________
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