diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 7 |
3 files changed, 21 insertions, 9 deletions
diff --git a/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs index db175b45a..13bf132ee 100644 --- a/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs +++ b/win/CS/HandBrakeWPF/Isolation/BackgroundServiceConnector.cs @@ -108,13 +108,18 @@ namespace HandBrakeWPF.Isolation "HandBrake.Server.exe", port)
{
UseShellExecute = false,
- CreateNoWindow = false,
+ CreateNoWindow = true,
+ RedirectStandardOutput = true,
};
backgroundProcess = new Process { StartInfo = processStartInfo };
backgroundProcess.Start();
}
+ // When the process writes out a line, it's pipe server is ready and can be contacted for
+ // work. Reading line blocks until this happens.
+ backgroundProcess.StandardOutput.ReadLine();
+
ThreadPool.QueueUserWorkItem(delegate
{
try
@@ -141,16 +146,16 @@ namespace HandBrakeWPF.Isolation /// </summary>
public void Disconnect()
{
- if (backgroundProcess != null && !backgroundProcess.HasExited)
+ try
{
- try
+ if (backgroundProcess != null && !backgroundProcess.HasExited)
{
Service.Unsubscribe();
}
- catch (Exception exc)
- {
- this.errorService.ShowError("Unable to disconnect from service", "It may have already close. Check for any left over HandBrake.Server.exe processes", exc);
- }
+ }
+ catch (Exception exc)
+ {
+ this.errorService.ShowError("Unable to disconnect from service", "It may have already close. Check for any left over HandBrake.Server.exe processes", exc);
}
}
diff --git a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs index 504024b43..322d30f9f 100644 --- a/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrakeWPF/Isolation/IsolatedEncodeService.cs @@ -84,7 +84,7 @@ namespace HandBrakeWPF.Isolation {
get
{
- return Service.EncodeActivityLog;
+ return this.IsConnected ? this.Service.EncodeActivityLog : "Unable to connect to background worker service ...";
}
}
@@ -95,7 +95,7 @@ namespace HandBrakeWPF.Isolation {
get
{
- return Service.IsEncoding;
+ return this.IsConnected && this.Service.IsEncoding;
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index a22fa83d9..3e8b5709f 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -827,6 +827,13 @@ namespace HandBrakeWPF.ViewModels isolatedScanService.Disconnect();
}
+ IIsolatedEncodeService isolatedEncodeService = this.encodeService as IIsolatedEncodeService;
+ if (isolatedEncodeService != null)
+ {
+ // Kill any background services for this instance of HandBrake.
+ isolatedEncodeService.Disconnect();
+ }
+
// Unsubscribe from Events.
this.scanService.ScanStared -= this.ScanStared;
this.scanService.ScanCompleted -= this.ScanCompleted;
|