From 4110f36f29bf22f1aea00f087b353b3db89849b2 Mon Sep 17 00:00:00 2001 From: Wilco Boele Date: Wed, 17 Jan 2024 21:28:34 +0100 Subject: [PATCH] Added ConfigureAwait(false) after GetAsync method of HttpClient to let the code after the callback (await) run in the same thread as created in the GetAsync method. By default this is not the case and when running this code on the UI thread it will cause the UI thread to hang (deadlock). --- MdXaml/ImageLoaderManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdXaml/ImageLoaderManager.cs b/MdXaml/ImageLoaderManager.cs index 850ef9c..ebdf63f 100644 --- a/MdXaml/ImageLoaderManager.cs +++ b/MdXaml/ImageLoaderManager.cs @@ -104,7 +104,7 @@ private static async Task> OpenStreamAsync(Uri resourceUrl) { case "http": case "https": - var httpResult = await s_client.GetAsync(resourceUrl); + var httpResult = await s_client.GetAsync(resourceUrl).ConfigureAwait(false); if (httpResult.StatusCode == HttpStatusCode.OK) { var webstream = await httpResult.Content.ReadAsStreamAsync();