From 2424a8ac8db863bbcee55d384d6268ce00ed6016 Mon Sep 17 00:00:00 2001 From: chylex Date: Tue, 18 Jul 2023 18:56:27 +0200 Subject: [PATCH] Fix UI freezing due to attachment download statistics being updated on the wrong thread --- app/Desktop/Main/Pages/AttachmentsPageModel.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Desktop/Main/Pages/AttachmentsPageModel.cs b/app/Desktop/Main/Pages/AttachmentsPageModel.cs index f6073be..f2b7911 100644 --- a/app/Desktop/Main/Pages/AttachmentsPageModel.cs +++ b/app/Desktop/Main/Pages/AttachmentsPageModel.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Threading; +using Avalonia.Threading; using DHT.Desktop.Common; using DHT.Desktop.Main.Controls; using DHT.Server.Data; @@ -134,9 +136,9 @@ sealed class AttachmentsPageModel : BaseModel, IDisposable { } private void DownloadThreadOnOnItemFinished(object? sender, DownloadItem e) { - ++doneItemsCount; + Interlocked.Increment(ref doneItemsCount); - UpdateDownloadMessage(); + Dispatcher.UIThread.Invoke(UpdateDownloadMessage); downloadStatisticsComputer.Recompute(); }