From eb8ac889a4b145540737ec557aadd566f46e403f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Mon, 22 Jun 2020 11:31:42 +0200 Subject: [PATCH] SEBWIN-408: Made favicon loading asynchronous. --- .../BrowserApplicationInstance.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index b8d10e9d..e792bfb0 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -281,16 +281,19 @@ namespace SafeExamBrowser.Browser private void DisplayHandler_FaviconChanged(string uri) { - var request = new HttpRequestMessage(HttpMethod.Head, uri); - var response = httpClient.SendAsync(request).ContinueWith(task => + Task.Run(() => { - if (task.IsCompleted && task.Result.IsSuccessStatusCode) + var request = new HttpRequestMessage(HttpMethod.Head, uri); + var response = httpClient.SendAsync(request).ContinueWith(task => { - Icon = new BrowserIconResource(uri); + if (task.IsCompleted && task.Result.IsSuccessStatusCode) + { + Icon = new BrowserIconResource(uri); - IconChanged?.Invoke(Icon); - window.UpdateIcon(Icon); - } + IconChanged?.Invoke(Icon); + window.UpdateIcon(Icon); + } + }); }); }