Multithreading and NSNotifications
Multithreading and NSNotifications
- Subject: Multithreading and NSNotifications
- From: Andrew Keller <email@hidden>
- Date: Mon, 21 Nov 2005 15:56:55 -0500
Hello,
I'd really appreciate it if somebody could give me some advice with
this. Object A, my program's controller, allocates an object B of a
different class in the same thread. Object B will act as a worker
thread for a particular task (actually, it will launch an NSTask). It
doesn't even need to pass anything back to Object A when it finishes.
Later on, object A decides it is time to have object B do something
in a different thread, so I use NSThread's
detachNewThreadSelector: ... message. However, I want this process
that object B is working on to be cancelable at a particular point
without much overhead, so I thought I would have object A post an
NSNotification. Optimally, object B would have an opportunity to
respond to that NSNotification at some point in the thread's
execution, but how would I go about doing this? I tried something
like adding a [[NSRunLoop currentRunLoop] run] call in the middle of
the method but I think it could be violating some thread safety
issues / causing me problems since I get some sporadic crashes. How
could this be implemented / is there a better way to do this?
Andrew Keller
_______________________________________________
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