summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Encode
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-02-02 10:56:34 +0000
committersr55 <[email protected]>2019-02-05 19:43:33 +0000
commit16a6d1a928b303f5536649744fdbf7875471b7fd (patch)
tree2c93517b5766255e6d481b764103ea6012593d18 /win/CS/HandBrakeWPF/Services/Encode
parent52be3306d5fa738330b3469c3d39d5e20a18c76a (diff)
WinGui: Make the disposal of services more aggressive. May Fix or help in #1851
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Encode')
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 382dd7cf9..ca4100b62 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -143,6 +143,10 @@ namespace HandBrakeWPF.Services.Encode
if (this.instance != null)
{
this.instance.StopEncode();
+ this.instance.EncodeCompleted -= this.InstanceEncodeCompleted;
+ this.instance.EncodeProgress -= this.InstanceEncodeProgress;
+ this.instance.Dispose();
+ this.instance = null;
this.ServiceLogMessage("Encode Stopped");
}
}
@@ -209,11 +213,24 @@ namespace HandBrakeWPF.Services.Encode
string hbLog = this.ProcessLogs(this.currentTask.Destination, this.isPreviewInstance, this.currentConfiguration);
long filesize = this.GetFilesize(this.currentTask.Destination);
- // Raise the Encode Completed EVent.
+ // Raise the Encode Completed Event.
this.InvokeEncodeCompleted(
e.Error
? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination, hbLog, filesize)
: new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination, hbLog, filesize));
+
+ // Cleanup
+ try
+ {
+ this.instance.EncodeCompleted -= this.InstanceEncodeCompleted;
+ this.instance.EncodeProgress -= this.InstanceEncodeProgress;
+ this.instance.Dispose();
+ this.instance = null;
+ }
+ catch (Exception exc)
+ {
+ this.ServiceLogMessage("Failed to cleanup Encode instance: " + exc );
+ }
}
private long GetFilesize(string destination)