Re: Are NSWindowDidResizeNotifications permitted to arrive on the heartbeat thread?
Re: Are NSWindowDidResizeNotifications permitted to arrive on the heartbeat thread?
- Subject: Re: Are NSWindowDidResizeNotifications permitted to arrive on the heartbeat thread?
- From: Milton Sagen <email@hidden>
- Date: Tue, 16 Aug 2005 14:03:21 -0700
the first line in
http://developer.apple.com/documentation/Cocoa/Conceptual/
Notifications/index.html#//apple_ref/doc/uid/10000043i
states: Regular notification centers deliver notifications on the
thread in which the notification was posted.
On Aug 16, 2005, at 13:52, Tim Gogolin wrote:
Does AppKit send UI notifications on non-main threads? Most of
what I understand about AppKit lore says to do all UI tasks on the
main thread only.
I wanted to listen to NSWindowDidResizeNotification notifications
on a specific window and (through a bug on my part) wound up
listening to ALL NSWindow resizes (I accidently passed 'nil' for
the 'object' parameter). I was very surprised to get a
NSNotification selector called on the UI heartbeat thread. I've
fixed my code to only listen to the window I care about and life is
good again (the notifications seem to be coming on the main thread
now), but I'm still very curious... does listening to
NSWindowDidResizeNotification for all NSWindows (by passing 'nil'
for the 'object' param) intentionally result in getting some of
those notifications while executing on the heartbeat thread? Seems
like kind of shaky behavior on AppKit's part.
// pseudo code
- (void) setPanel: (int) whichPanel contentView: (AgValuePtr)
contentValue
{
NSWindow* aWindow = [ foo getSpecialWindow ]; // my bug
resulted in this being nil!
[ [ NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(specialWindowDidResize:)
name: NSWindowDidResizeNotification
object: aWindow ];
}
-(void) specialWindowDidResize: (NSNotification*) n
{
// Code that was unhappy when executing on a non-main thread
}
Is this a bug in AppKit, or is this permitted behavior?
(I could probably change my code back and get a stack trace showing
the problem if that would help diagnose it)
--
Tim Gogolin
Adobe Systems
_______________________________________________
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
_______________________________________________
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