Async IValueConverter freezes application #16901
Unanswered
LSXAxeller
asked this question in
Q&A
Replies: 2 comments 3 replies
-
See this https://docs.avaloniaui.net/docs/guides/data-binding/how-to-bind-to-a-task-result |
Beta Was this translation helpful? Give feedback.
3 replies
-
You're blocking your UI thread with the GetAwaiter().GetResult() chain. See https://devblogs.microsoft.com/dotnet/configureawait-faq/#i’m-using-getawaiter().getresult().-do-i-need-to-use-configureawait(false)11 ConfigureAwait(false) here doesn't do anything. So you'll instead need to make your Convert method properly async, or find some other way to achieve the same results. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to create an asynchronous converter in Avalonia, but I'm running into an issue where the program freezes when calling
.ConfigureAwait(false).GetAwaiter().GetResult()
or even just.Result
on my async method.Here's the code for my converter:
The
ConvertToSubtitlesLanguage
method fetches subtitles languages asynchronously using YoutubeExplode library.Here's how I'm using the converter in my XAML:
I understand that blocking the UI thread with synchronous waits is a bad practice, but I'm unsure how to implement an asynchronous converter in Avalonia correctly.
What I've Tried:
.ConfigureAwait(false).GetAwaiter().GetResult()
: The program freezes..Result
: The program freezes.TaskCompletionNotifier
as suggested in this gist: AsyncConverter.cs for WPF: Still no luck.Any help or insights would be greatly appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions