Re: App crashes on thread exit
Re: App crashes on thread exit
- Subject: Re: App crashes on thread exit
- From: Cameron Hayne <email@hidden>
- Date: Sat, 12 Oct 2002 12:02:02 -0400
On 12/10/02 10:20 am, "Fabio Genoese" <email@hidden> wrote:
>
I use a Unix tool in my Cocoa application. Since I wanted the GUI not
>
to be blocked when calling the tool/handling output/returning output I
>
put this stuff into a separate thread using
>
'detachNewThreadSelector:...'. All is fine, I get the correct output,
>
store it in the datasource of my NSTableView and update the GUI in the
>
AppKit thread with the NSThreadWillExitNotification.
The doc for NSThreadWillExitNotification says:
----------------------------
NSThread posts this notification when it receives the exit message, before
the thread exits. Observer methods invoked to receive this notification
execute in the exiting thread, before it exits.
----------------------------
So this means that your updating of the GUI happens in the worker thread,
not the main (AppKit) thread as you had thought.
Usually you just set a flag in the worker thread and check this flag in the
main thread (protected with NSLock) or else set up more sophisticated
communication between threads. But, assuming you are targeting Jaguar, maybe
you could use the new performSelectorOnMainThread method (see NSObject or
the Foundation release notes).
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.