Added Dispose on IProcessable.Completed in case form is created but never shown.

This commit is contained in:
Michael Bucari-Tovo 2021-08-12 12:23:55 -06:00
parent 56a48c04bf
commit 448fd78b8f

View File

@ -1,4 +1,5 @@
using DataLayer; using DataLayer;
using Dinah.Core.Windows.Forms;
using FileLiberator; using FileLiberator;
using System; using System;
@ -24,14 +25,17 @@ namespace LibationWinForms.BookLiberation
//IStreamable.StreamingCompleted, and the IProcessable //IStreamable.StreamingCompleted, and the IProcessable
//events need to live past that event. //events need to live past that event.
processable.Completed += OnUnsubscribeAll; processable.Completed += OnUnsubscribeAll;
processable.Completed += OnCompleetdDispose;
} }
} }
private void OnCompleetdDispose(object sender, LibraryBook e) => this.UIThread(() => Dispose());
private void OnUnsubscribeAll(object sender, LibraryBook e) private void OnUnsubscribeAll(object sender, LibraryBook e)
{ {
if (Streamable is IProcessable processable) if (Streamable is IProcessable processable)
{ {
processable.Completed -= OnUnsubscribeAll; processable.Completed -= OnUnsubscribeAll;
processable.Completed -= OnCompleetdDispose;
processable.Begin -= OnBegin; processable.Begin -= OnBegin;
processable.Completed -= OnCompleted; processable.Completed -= OnCompleted;
processable.StatusUpdate -= OnStatusUpdate; processable.StatusUpdate -= OnStatusUpdate;