Re: Main Thread stoppin Background Thread
Re: Main Thread stoppin Background Thread
- Subject: Re: Main Thread stoppin Background Thread
- From: Gregory Weston <email@hidden>
- Date: Fri, 28 Nov 2008 15:50:41 -0500
John Love wrote:
Reference page 43 of Apple's MultiThreading.pdf.
I'm assuming you mean:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/Multithreading.pdf>
I conclude from this page that the preferred, if not only, way to have
the main thread stop the background thread is through KVC.
I don't see anything about a "preferred, if not only, way" for
example. I see a recommendation that you should consider up front the
need to signal to the thread that it should bail out and a
description of "one way" to achieve that. That "one way" relies on
you having read and understood the discussion of custom run loop
input sources later on in the document.
I also don't see any mention at all of KVC except for the fact that
valueForKey: is used to retrieve a value from the thread's
dictionary. But that's got nothing to do with the inter-thread
signaling.
Before I continue to inflict more pain on myself, why can't I simply
toggle the value of an instance variable of the class' interface from
the main thread and have the backgroundThreadRoutine look at the same
variable and break out of the background thread if its a certain
value?
I have been totally unsuccessful in this simpler-to-understand
approach; therefore, I am beginning to study KVC and its use on page
43 of Apple's doc.
The technique you want to use *should* work. As long as you actually
do it correctly. You haven't shown us what you're doing or described
the way in which it's failing, so we can't really help there.
_______________________________________________
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