Fix UI freezing due to attachment download statistics being updated on the wrong thread

This commit is contained in:
chylex committed 2023-07-18 18:56:34 +02:00
1 parent e7705587c2
commit 2424a8ac8d
1 file changed
+4 -2
@@ -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();
}