• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Multithreading and NSNotifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Custom NSOutlineView - Almost resolved
  • Next by Date: HOWTO : obtaning window Server 's list of all active window.
  • Previous by thread: Re: NSURLConnection not reentrant?
  • Next by thread: Re: Multithreading and NSNotifications
  • Index(es):
    • Date
    • Thread