I have an application for which the UI element includes an NSStatusItem
and a menu. Inside my application , I am using NSTask
asynchronously to perform some operation and I am using the output obtained using the NSFileHandleReadCompletionNotification
to update the menu. But now whenever I click and open the menu , the main runloop goes into NSEventTrackingRunLoopMode
and the notification posting fails. So basically with my menu open , no operation takes place on the main thread. Now I found a similar problem on this post but the accepted solution there does not seem to help. I understand that for NSNotificationCenter
, the NSRunloopDefaultMode
must not be blocked. Is there anyway to alter this bahaviour??? Can anyone please help ???
相关问题
- NSOutlineView drag line stuck + blue border
- iphone sdk see size of local file (one created
- How can you detect the connection and disconnectio
- QuickLook Plugin Failing with sandboxing error
- NSTextField font styling resets when selected
相关文章
- How can I vertically align my status bar item text
- Converting (u)int64_t to NSNumbers
- “getter” keyword in @property declaration in Objec
- NSMenuItem KeyEquivalent “ ”(space) bug
- Detect if cursor is hidden on Mac OS X
- NSNumberFormatter doesn't allow typing decimal
- Is subclassing NSNotification the right route if I
- Creating an NSMutableArray with a literal via muta
What I'm guessing is that you have an
NSFileHandle
that represents theNSTask
'sstdout
, and you've asked it to-readInBackgroundAndNotify
.The problem with this, as you've found, is that this only notifies when the runloop is in the default mode. If the runloop enters another mode (such as when a menu is open), then your notifications will queue up on the main runloop and will wait until the runloop re-enters the default mode.
What you want to use instead is the
-readInBackgroundAndNotifyForModes:
method, to which you would pass an array containing bothNSDefaultRunLoopMode
andNSEventTrackingRunLoopMode
. This would indicate to the runloop that you want to be notified of any available data when the runloop is either in the default mode or the event tracking mode.