I want my Vapor app to be able to create and show NSWindow
s on the host machine. For this I've edited main.swift
like this:
import AppKit
import App
import Vapor
var env = try Environment.detect()
try LoggingSystem.bootstrap(from: &env)
let app = Application(env)
defer { app.shutdown() }
try configure(app)
DispatchQueue.init(label: "com.myapp.vapor", qos: DispatchQoS.userInteractive).async {
try! app.run()
}
NSApplication.shared.run()
So Vapor runs in a separate queue, while NSApplication runs in the main queue. This works, but I need to call DispatchQueue.main.async
inside Vapor handlers, and I'd like to avoid it. Is it possible to extend Vapor application and set is as app delegate?