summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/CS/HandBrakeWPF/Instance/RemoteInstance.cs15
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs10
2 files changed, 22 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
index a6b7d7446..8cbdf014b 100644
--- a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
+++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs
@@ -45,6 +45,7 @@ namespace HandBrakeWPF.Instance
private Process workerProcess;
private Timer encodePollTimer;
private int retryCount = 0;
+ private bool encodeCompleteFired;
public RemoteInstance(ILog logService, IUserSettingService userSettingService, IPortService portService)
{
@@ -219,15 +220,23 @@ namespace HandBrakeWPF.Instance
private async void PollEncodeProgress()
{
+ if (encodeCompleteFired)
+ {
+ this.encodePollTimer?.Stop();
+ this.encodePollTimer.Dispose();
+ return;
+ }
+
ServerResponse response = null;
try
{
if (this.retryCount > 5)
{
- this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(4));
-
+ encodeCompleteFired = true;
this.encodePollTimer?.Stop();
+ this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(-11));
+
if (this.workerProcess != null && !this.workerProcess.HasExited)
{
this.workerProcess?.Kill();
@@ -277,6 +286,8 @@ namespace HandBrakeWPF.Instance
else if (taskState != null && taskState == TaskState.WorkDone)
{
this.encodePollTimer.Stop();
+ encodeCompleteFired = true;
+
if (this.workerProcess != null && !this.workerProcess.HasExited)
{
try
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index 1474df7e7..82504aa0e 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -47,8 +47,9 @@ namespace HandBrakeWPF.Services.Encode
private HBConfiguration currentConfiguration;
private bool isPreviewInstance;
private bool isLoggingInitialised;
+ private bool isEncodeComplete;
private int encodeCounter;
-
+
public LibEncode(IUserSettingService userSettingService, ILogInstanceManager logInstanceManager, int encodeCounter, IPortService portService) : base(userSettingService)
{
this.userSettingService = userSettingService;
@@ -223,6 +224,13 @@ namespace HandBrakeWPF.Services.Encode
{
this.IsEncoding = false;
+ if (isEncodeComplete)
+ {
+ return; // Prevent phantom events bubbling up the stack.
+ }
+
+ this.isEncodeComplete = true;
+
string completeMessage = "Job Completed!";
switch (e.Error)
{