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/HandBrake.ApplicationServices | |
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/HandBrake.ApplicationServices')
3 files changed, 26 insertions, 11 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index dbf598796..fa21353ed 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -373,6 +373,13 @@ namespace HandBrake.ApplicationServices.Services /// <param name="timeRemaining">Time Left</param>
private void EncodeOnEncodeProgress(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float avg, string timeRemaining)
{
+ if (!this.IsEncoding)
+ {
+ // We can get events out of order since the CLI progress is monitored on a background thread.
+ // So make sure we don't send a status update after an encode complete event.
+ return;
+ }
+
EncodeProgressEventArgs eventArgs = new EncodeProgressEventArgs
{
AverageFrameRate = avg,
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index 277a7c5b3..f6b6edf44 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -13,6 +13,7 @@ namespace HandBrake.ApplicationServices.Services using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
+ using System.Threading;
using System.Windows;
using HandBrake.ApplicationServices.EventArgs;
@@ -47,7 +48,12 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The host.
/// </summary>
- private ServiceHost host;
+ private static ServiceHost host;
+
+ /// <summary>
+ /// The shutdown flag.
+ /// </summary>
+ private static ManualResetEvent shutdownFlag;
#endregion
@@ -148,18 +154,20 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
public void Start(string port)
{
- using (this.host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))
+ using (host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))
{
// Setup a listener
- this.host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");
- this.host.Open();
- Console.WriteLine("::: HandBrake Isolation Server:::");
+ host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");
+ host.Open();
+ Console.WriteLine("::: HandBrake Isolation Server - Debug Console:::");
Console.WriteLine("Service Started. Waiting for Clients...");
// Setup the services we are going to use.
scanService = new ScanService(new UserSettingService()); // TODO this needs wired up with castle
encodeService = new Encode(new UserSettingService());
- Console.ReadLine();
+
+ shutdownFlag = new ManualResetEvent(false);
+ shutdownFlag.WaitOne();
}
}
@@ -186,10 +194,11 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
public void Stop()
{
- if (this.host != null)
+ if (host != null)
{
- this.host.Close();
- Application.Current.Shutdown();
+ host.BeginClose(null, null);
+ //host.Abort();
+ shutdownFlag.Set();
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Win32.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Win32.cs index 892c4bcad..acc8948a1 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/Win32.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/Win32.cs @@ -168,8 +168,7 @@ namespace HandBrake.ApplicationServices.Utilities /// </summary>
public static void AllowSleep()
{
- executor(
- () => SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS));
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
/// <summary>
|