summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs7
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ServerService.cs27
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/Win32.cs3
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>