Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DispatchQueue.main is not bound to main thread on Windows #846

Open
HeMet opened this issue Sep 20, 2024 · 0 comments
Open

DispatchQueue.main is not bound to main thread on Windows #846

HeMet opened this issue Sep 20, 2024 · 0 comments

Comments

@HeMet
Copy link

HeMet commented Sep 20, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant