From 0abc8cb07a4d6ca27d0a0c300a78957b610b773e Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 9 Apr 2020 21:07:12 +0100 Subject: WinGui: Allow the *experimental* process worker feature to be enabled though advanced preferences. When enabled, all encodes will run in a seperate worker process protecting the UI and queue from any serious crashes. --- win/CS/HandBrakeWPF/Instance/RemoteInstance.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'win/CS/HandBrakeWPF/Instance') diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs index dc52d0885..847e9cf4c 100644 --- a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs +++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs @@ -209,7 +209,7 @@ namespace HandBrakeWPF.Instance { if (this.retryCount > 5) { - this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(true)); + this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(4)); this.encodePollTimer?.Stop(); @@ -239,7 +239,7 @@ namespace HandBrakeWPF.Instance TaskState taskState = state != null ? TaskState.FromRepositoryValue(state.State) : null; - if (taskState != null && (taskState == TaskState.Working || taskState == TaskState.Muxing || taskState == TaskState.Searching)) + if (taskState != null && (taskState == TaskState.Working || taskState == TaskState.Searching)) { if (this.EncodeProgress != null) { @@ -259,15 +259,12 @@ namespace HandBrakeWPF.Instance else if (taskState != null && taskState == TaskState.WorkDone) { this.encodePollTimer.Stop(); - - this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(state.WorkDone.Error != 0)); - this.workerProcess?.Kill(); - } - else if (taskState == TaskState.Idle) - { - this.encodePollTimer.Stop(); - this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(state.WorkDone.Error != 0)); - this.workerProcess?.Kill(); + if (!this.workerProcess.HasExited) + { + this.workerProcess?.Kill(); + } + + this.EncodeCompleted?.Invoke(sender: this, e: new EncodeCompletedEventArgs(state.WorkDone.Error)); } } } -- cgit v1.2.3