1

I have an httpClient with async() methods, I need to use in sync methods called from the GUI thread. I cannot use the .Result property of the task because it causes a deadlock and freezes the GUI.

I have a solution with launching a new thread pool thread and executing an async method in it:

Task.Run(async () => { ApiInfo = await _apiClient.Get<ApiInfo>($"{Url}"); }).Wait();

This works, but because I'm new to async programming - I'm not sure if it's the preferred way for my situation?

Kiran Joshi
  • 1,758
  • 2
  • 11
  • 34
shtrule
  • 658
  • 10
  • 23

0 Answers0