Replies: 2 comments 3 replies
-
Note that with MacOS you have to run GUI on your first thread. Calls to any GUI-related functions from other threads will result in a crash. |
Beta Was this translation helpful? Give feedback.
-
As @kekekeks mentions you're hitting the fact that MacOS is quite prescriptive about how the main loop runs. The is probably a way around it (using [this](https://developer.apple.com/documentation/appkit/nsapplication/1428436-runmodalforwindow?language=objc for example?) but there's likely going to be a impedance between MacOS and other platforms to overcome. It's probably a silly question, but can you make your console application async? Async (Disclaimer: this isn't my area of expertise so could be I've got it wrong) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
Intended Scenario
We have a console application which runs background work while may launch ephemerous dialogs for user interaction.
E.g.:
We currently have this implemented in WPF by simply calling WPF ShowDialog, which is already sync, on STA Thread, which is not the Console Application main thread.
MainLoop API Misuse Approach
I've understood that calling the
Dispatcher.UIThread.MainLoop
multiple times, after the methodShow
, its an API misuse: #5229Although it used to work fine on
v0.8.3
and still works (v0.10.2
) on Windows, while on macOS it throwsRunLoop failed
.There is an attached sample project (AvaloniaBadMainLoop.zip) using this approach just as an example for the intended scenario.
Full Async Approach
I've also come up with an attempt of making sure the Console App main work is not running on the UI Thread so it can avoid awaiting for dialog result inside the UI, blocking the thread.
But in this case the App just terminates with no message:
See sample project: AvaloniaAsyncAwaitDialog.zip
ShowDialogAsync
snippet:Question
So I would like to know if there is a known proper way of opening dialogs and wait for their result.
Thank you.
Attachments
AvaloniaBadMainLoop.zip
AvaloniaAsyncAwaitDialog.zip
Beta Was this translation helpful? Give feedback.
All reactions