In the paper written about unstructured tasks:
We might need to ... initiate asynchronous work from synchronous code...
So if I understand right, If we want to initiate a concurrency job from the main thread method of UIKit View controller View did load is only to detaching Task, because the run loop of UIApplication is synchronous. Also there written
they remain a very important building block especially for more free-form usages and integration with legacy APIs.
Also If I see right, there is nothing to start a UIKit or AppKit application asynchronously, something like this
@main
struct App {
static func main() async {
async let k = App().runLoop(number: 1)
async let n = App().runLoop(number: 2)
print("DONE: \(await k), \(await n)")
}
func runLoop(number: Int) async -> Int {
var line = ""
while line != "done" {
if let l = readLine() { // wait event
line = l
// render
print("command: \(line) in runloop: \(number)")
//
}
}
return 0
}
}
Therefore, I would to ask if it is worth expecting that someday there will be async method of NSApplication's run():
class NSApplication {
func run() async {}
}
Or am I wrong in understanding async?