add thread safety
This commit is contained in:
parent
7b3c857042
commit
491aa67a81
@ -43,14 +43,14 @@ namespace LibationWinForms.BookLiberation
|
|||||||
private void timer_Tick(object sender, EventArgs e)
|
private void timer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// if no update in the last 30 seconds, display frozen label
|
// 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)
|
if (lastUpdateLbl.Visible)
|
||||||
{
|
{
|
||||||
var diff = lastDownloadProgress - DateTime.Now;
|
var diff = lastDownloadProgress - DateTime.Now;
|
||||||
var min = (int)diff.TotalMinutes;
|
var min = (int)diff.TotalMinutes;
|
||||||
var minText = min > 0 ? $"{min}min " : "";
|
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();
|
private void DownloadForm_FormClosing(object sender, FormClosingEventArgs e) => timer.Stop();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user