`DispatchQueue.main` is not bound to main thread on Windows
HeMet opened this issue · 1 comments
HeMet commented
@main
struct EntryPoint3: AsyncParsableCommand {
@MainActor
mutating func run() async throws {
print("Thread is main: \(Thread.isMainThread)")
print("Current Thread ID: \(GetCurrentThreadId())")
MainActor.preconditionIsolated()
await withCheckedContinuation { con in
DispatchQueue.main.async {
print("Thread is main (queue): \(Thread.isMainThread)")
print("Current Thread ID (queue): \(GetCurrentThreadId())")
MainActor.preconditionIsolated()
con.resume()
}
}
print("completed")
}
}Output:
Thread is main: false
Current Thread ID: 498188
Thread is main (queue): false
Current Thread ID (queue): 498188
completed
Thread on Swift Forums https://forums.swift.org/t/mainactor-behaves-different-on-windows-and-macos/74742