DispatchQueue.main not working (on Windows)
#38
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
Closures passed to
DispatchQueue.main.asyncwill never be called. Similarly, Swift ConcurrencyTasks scheduled to run on@MainActorare never called.To Reproduce
These print statements are never executed when using Adwaita for Swift on Windows:
Expected behavior
I expect that the Main Dispatch Queue and the Main Actor can be used normally. Alternatively, the library should surface a similar API to run code on the Main Thread.
Additional context
I assume, to make this work, the GTK run loop must be integrated with libdispatch. Maybe this can be helpful: https://stackoverflow.com/questions/10291972/integrating-a-custom-run-loop-with-libdispatch
Thanks for opening the issue! I will look into this at some point. Currently, you can use Idle which calls GLib.idle_add to add functions to the main context (e.g. for updating the UI).
@david-swift Thanks for your response! Interestingly, I have been working on a workaround and stumbled on
g_idle_addmyself.Here is my workaround for anyone interested. It works but is obviously not optimal:
This creates a new
MainActorwhich can be used as a replacement for the built-inMainActorto make Swift Concurrency work with Adwaita for Swift on Windows.@s-k just wanted to chime in - I'm working on a Linux app w/ Swift 6 concurrency and your
MainActorbits unblocked me. Thanks for sharing!