Stop automatic processing if form is closed instead of crashing.
This commit is contained in:
parent
f284f53edd
commit
d73701c939
@ -24,13 +24,18 @@ namespace LibationWinForms.BookLiberation
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteLine(string text)
|
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()
|
public void FinalizeUI()
|
||||||
{
|
{
|
||||||
keepGoingCb.Enabled = false;
|
keepGoingCb.Enabled = false;
|
||||||
logTb.AppendText("");
|
|
||||||
|
if (!IsDisposed)
|
||||||
|
logTb.AppendText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AutomatedBackupsForm_FormClosing(object sender, FormClosingEventArgs e) => keepGoingCb.Checked = false;
|
private void AutomatedBackupsForm_FormClosing(object sender, FormClosingEventArgs e) => keepGoingCb.Checked = false;
|
||||||
|
|||||||
@ -66,9 +66,9 @@ namespace LibationWinForms.BookLiberation
|
|||||||
|
|
||||||
(Action unsibscribeEvents, LogMe logMe) = attachToBackupsForm(backupBook, automatedBackupsForm);
|
(Action unsibscribeEvents, LogMe logMe) = attachToBackupsForm(backupBook, automatedBackupsForm);
|
||||||
|
|
||||||
automatedBackupsForm.FormClosing += (_, __) => unsibscribeEvents();
|
|
||||||
|
|
||||||
await new BackupLoop(logMe, backupBook, automatedBackupsForm).RunBackupAsync();
|
await new BackupLoop(logMe, backupBook, automatedBackupsForm).RunBackupAsync();
|
||||||
|
|
||||||
|
unsibscribeEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BackupBook getWiredUpBackupBook(EventHandler<LibraryBook> completedAction)
|
private static BackupBook getWiredUpBackupBook(EventHandler<LibraryBook> completedAction)
|
||||||
@ -496,6 +496,9 @@ An error occurred while trying to process this book
|
|||||||
if (!keepGoing)
|
if (!keepGoing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (AutomatedBackupsForm.IsDisposed)
|
||||||
|
break;
|
||||||
|
|
||||||
if (!AutomatedBackupsForm.KeepGoing)
|
if (!AutomatedBackupsForm.KeepGoing)
|
||||||
{
|
{
|
||||||
if (AutomatedBackupsForm.KeepGoingVisible && !AutomatedBackupsForm.KeepGoingChecked)
|
if (AutomatedBackupsForm.KeepGoingVisible && !AutomatedBackupsForm.KeepGoingChecked)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user