• 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
Re: NSPanel as Sheet and controlling the run loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPanel as Sheet and controlling the run loop


  • Subject: Re: NSPanel as Sheet and controlling the run loop
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Thu, 8 Apr 2004 06:22:15 -0700

Hello...

Actually, I don't think NSNotifications provide the kind of thread safety you imply. In fact, they are a bit dangerous in that regard, since (as far as I know) the registered methods for observers are actually run in the same thread that posts the notification.

You would probably need to use one of the performSelectorOnMainThread: variants to force the notification to be posted on the main thread.


Louis

...
If processing is going to take longer than this amount of time, then rather decouple the processing from the UI thread by spawning another thread that actually does the processing and reports back to the UI by sending notifications of progress via NSNotificationManager. The use of notifications nicely decouples the two threads. I personally do not like using NSNotifications, and use a model based on the Smalltalk dependency patterns, although this introduces some additional complexity in terms of making sure two threads do not attempt to access shared data at the same time, which is not a problem when using NSNotifications.

Hope this comment is of value.

Vincent
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSPanel as Sheet and controlling the run loop
      • From: Steve Palmer <email@hidden>
References: 
 >NSPanel as Sheet and controlling the run loop (From: "Alexander F. Hartner" <email@hidden>)
 >Re: NSPanel as Sheet and controlling the run loop (From: Larry Fransson <email@hidden>)
 >Re: NSPanel as Sheet and controlling the run loop (From: Vincent Coetzee <email@hidden>)

  • Prev by Date: Getting the current cursor image
  • Next by Date: Re: Passing C Style Function Callbacks in Cocoa
  • Previous by thread: Re: NSPanel as Sheet and controlling the run loop
  • Next by thread: Re: NSPanel as Sheet and controlling the run loop
  • Index(es):
    • Date
    • Thread