Re: NSPanel as Sheet and controlling the run loop
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.