Skip navigation.
 
mlNSFileHandleReadCompletionNotification(s) not being posted when app is inactive
FROM : John Clayton
DATE : Sat Apr 09 00:19:50 2005

Hello,

This is a reformulation of a previous post, but I have pinpointed the
problems I am having to the subject above, so I thought I'd try again
and see if anyone knows how to work around this.

Basically, I am using DO to communicate between two threads: a client,
responsible for display, and a server that is following a log file. I
initially tried to use NSFilehandle readInBackgroundAndNotify:] to tail
the file and send the data back to the cilent.  This works for a bit,
then the NSFileHandleReadCompletionNotification's seem to stop coming
in the server—until I deactivate the app and reactivate it—then bango!
more notifications.  Or, as soon as the app becomes inactive
notifications stop instantly and restart when the app becomes active
again.

I've been able to determine that [[NSRunLoop currentRunLoop] runMode]
returns the string "null" when the app goes inactive.

I tried registering the notifications on different run loop modes using
readInBackgroundAndNotifyForModes: but this has no effect.  I can
however use an NSInputStream.  If I do this: [iStream
scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode]; I can keep getting callbacks from the
runLoop under all conditions.  It's just inconvenient to re-implement
seeking and keep alive in a custom stream subclass.

So, does anyone know how I can keep the
NSFileHandleReadCompletionNotification's coming even when the app goes
inactive, and get them not to stop or mysteriously after a few moments
of working?

I do keep calling readInBackgroundAndNotifyForModes from my handler,
BTW.

Thanks!

—John

Related mailsAuthorDate
No related mails found.