discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNotification and NSRunLoop


From: Richard Frith-Macdonald
Subject: Re: NSNotification and NSRunLoop
Date: Wed, 29 Oct 2003 18:23:12 +0000


On Wednesday, October 29, 2003, at 05:54 PM, Chris B. Vetter wrote:

On Wed, 29 Oct 2003 06:18:51 +0000
Richard Frith-Macdonald <richard@brainstorm.co.uk> wrote:
On Wednesday, October 29, 2003, at 01:29 AM, Yen-Ju Chen wrote:
 Why does it happen ?
 Do I have to use NSRunLoop in order to receive NSNotification in
 the middle of while loop ?
Yes ... events  only arrive while a run loop is running ... so you
need to run the runloop within your while loop.
[...]

I was playing with sockets the other day and ran into a similar problem,
Yen-Ju was having (with respect to NSRunLoop and NSNotification).

Basically I did the same as you suggested (put NSRunLoop inside a loop)
and never received any notifications, until the while() finished. When I put the while() in a separate method, added it to a timer and fired that
one off, it worked... Weird.

Do you have any example code I could try out?  I've certainly used that
sort of code successfully in the past ... but some particular set of circumstances
might be triggering a bug of some kind.

One thing I can think of is that notifications are actually only received by the default run loop of the main thread (I don't know if this is Apple behavior too)
so running another loop will not enable notifications to be received.
I *think* this is correct ... but perhaps it's a bug to be fixed and the notification
reception should be automatically added to all run loops.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]