My macos KN applications write in console: `Discar...
# kotlin-native
a
My macos KN applications write in console:
Discarding message for event 0 because of too many unprocessed messages
How can I process messages from OS?
l
Maybe by calling
CFRunLoop()
?
a
Hm… “The only time you need to run a run loop explicitly is when you create secondary threads for your application” I don’t use secondary thread all the time (only sometimes for microhttpser library). How can I understand what and when have I to use?
a
Hi, @aleksey.tomin! As far as I can see, this paragraph is not about your case, if you’re not using
NSApplication().run()
, you should run loop manually.
a
Turns out I’m using NSApplication somewhere. If I add
NSApplication().run()
I have error message
Creating more than one Application
a
Okay, than you can try to get this instance (using `NSApp`public variable) and execute
run()
. Or, maybe CFRunLoop makes more sense here.
a
Copy code
var app = NSApp
        println("existing: $app")
        app = app?: NSApplication()
        println("active: ${app.active}")
        app.run()
Result:
Copy code
existing: null
active: false
...
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Creating more than one Application'
🤯
s
Your code fragment doesn’t work on Obj-C either. This one works:
Copy code
var app = NSApplication.sharedApplication
println("existing: $app")
app = app?: NSApplication()
println("active: ${app.active}")
app.run()
a
Thank you! Just
NSApplication.sharedApplication
isn’t nullable -
NSApplication.sharedApplication.run()
is OK
👍 1