Dear all,

I just learned the technique of asynchronous notification. This is the first
time for me to use it in my system. However, I got a weird problem. Only
synchronous notification works well. If replacing the synchronous
notification lines of code with asynchronous ones, it does not work.

My system is a Cocoa Application. I know RunLoop is created automatically in
such a project. So asynchronous notification should work. The primary code
is as follows.

        ......

        // The following two lines are the parameters to be transmitted with
the notification.
        NSMutableDictionary *connectionDisconnectedDictionary =
[[[NSMutableDictionary alloc] initWithCapacity:5] autorelease];
        [connectionDisconnectedDictionary setObject:serviceKey forKey:@
"SERVICE_KEY"];

        // This line does not work.
//      [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED"
object:self userInfo:connectionDisconnectedDictionary]
postingStyle:NSPostWhenIdle];

        // This line works well.
//      [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostNow];

         // It does not work.
//       [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostASAP];

        // It works
        [[NSNotificationCenter defaultCenter]
postNotificationName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary];

        ......

The registration and events code is the same. So I felt confused.

Could you please give me a hand? What reasons might cause the above problem?

Best,
Bing
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to