Stop automatic processing if form is closed instead of crashing.

This commit is contained in:
Michael Bucari-Tovo 2021-07-03 20:34:50 -06:00
parent f284f53edd
commit d73701c939
2 changed files with 13 additions and 5 deletions

View File

@ -25,11 +25,16 @@ namespace LibationWinForms.BookLiberation
}
public void WriteLine(string text)
=> logTb.UIThread(() => logTb.AppendText($"{DateTime.Now} {text}{Environment.NewLine}"));
{
if (!IsDisposed)
logTb.UIThread(() => logTb.AppendText($"{DateTime.Now} {text}{Environment.NewLine}"));
}
public void FinalizeUI()
{
keepGoingCb.Enabled = false;
if (!IsDisposed)
logTb.AppendText("");
}

View File

@ -66,9 +66,9 @@ namespace LibationWinForms.BookLiberation
(Action unsibscribeEvents, LogMe logMe) = attachToBackupsForm(backupBook, automatedBackupsForm);
automatedBackupsForm.FormClosing += (_, __) => unsibscribeEvents();
await new BackupLoop(logMe, backupBook, automatedBackupsForm).RunBackupAsync();
unsibscribeEvents();
}
private static BackupBook getWiredUpBackupBook(EventHandler<LibraryBook> completedAction)
@ -496,6 +496,9 @@ An error occurred while trying to process this book
if (!keepGoing)
return;
if (AutomatedBackupsForm.IsDisposed)
break;
if (!AutomatedBackupsForm.KeepGoing)
{
if (AutomatedBackupsForm.KeepGoingVisible && !AutomatedBackupsForm.KeepGoingChecked)