From 491aa67a8171e21cff79a301741dd3c63fd5093e Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Sun, 18 Jul 2021 10:44:54 -0400 Subject: [PATCH] add thread safety --- LibationWinForms/BookLiberation/DownloadForm.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LibationWinForms/BookLiberation/DownloadForm.cs b/LibationWinForms/BookLiberation/DownloadForm.cs index c6083826..de13e067 100644 --- a/LibationWinForms/BookLiberation/DownloadForm.cs +++ b/LibationWinForms/BookLiberation/DownloadForm.cs @@ -43,14 +43,14 @@ namespace LibationWinForms.BookLiberation private void timer_Tick(object sender, EventArgs e) { // if no update in the last 30 seconds, display frozen label - lastUpdateLbl.Visible = lastDownloadProgress.AddSeconds(30) < DateTime.Now; + lastUpdateLbl.UIThread(() => lastUpdateLbl.Visible = lastDownloadProgress.AddSeconds(30) < DateTime.Now); if (lastUpdateLbl.Visible) { var diff = lastDownloadProgress - DateTime.Now; var min = (int)diff.TotalMinutes; var minText = min > 0 ? $"{min}min " : ""; - - lastUpdateLbl.Text = $"Frozen? Last download activity: {minText}{diff.Seconds}sec ago"; + + lastUpdateLbl.UIThread(() => lastUpdateLbl.Text = $"Frozen? Last download activity: {minText}{diff.Seconds}sec ago"); } } private void DownloadForm_FormClosing(object sender, FormClosingEventArgs e) => timer.Stop();