Open perfect100 opened 2 months ago
It's something good to mention in the documentation, but I don't think it's possible to support. IFileDialog requires main thread to be a STA thread.
See https://github.com/dotnet/roslyn/issues/22112
Also, "async Main" break macOS apps fundamentally too, but for different reasons. Only first physical thread can be main thread there.
Woo, that's really teach me a great lesson. I have spent 3 days to investigate the issue. Many thanks @maxkatz6
Describe the bug
If the
Main
entrance point is avoid
method, it works.However, if the function is async , the folder picker will never return, and UI blocks.
In this scenario, the code will be blocked here: https://github.com/AvaloniaUI/Avalonia/blob/eb7b6fe8435dfc3eae45907010b293f1ebc8d129/src/Windows/Avalonia.Win32/Win32StorageProvider.cs#L155
To Reproduce
Only can reproduce in some special machine... Most of the machines work well
Expected behavior
It should always work, no matter of the
Main
method isasync
or not.Avalonia version
11.1.0-beta1
OS
Windows
Additional context
If I debug into this function in
Avalonia.Win32.Win32StorageProvider.ShowFilePicker()
step by step, the folder picker shows normally.