diff options
author | sr55 <[email protected]> | 2012-09-02 15:12:06 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-09-02 15:12:06 +0000 |
commit | 56bf9b80b9b55ecaec9855addda41898261d26b1 (patch) | |
tree | c2cf34ebd4d7e8695c2764a0a813ad11a7f035a8 /win/CS/HandBrakeWPF | |
parent | bf7e3f6e6ef524ef8245b57f5e11b3e101525c99 (diff) |
WinGui: Further work and fixes on the Process Isolation Service
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4929 b64f7644-9d1e-0410-96f1-a4d463321fa5
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;
|