summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-09-26 16:12:25 +0100
committersr55 <[email protected]>2020-09-26 16:12:25 +0100
commit32474ffae290dd82f233fe62d2dc39c47693e7a7 (patch)
tree8e79820e13142bcd61bc11a45b5c4077ed58e07d /win/CS
parente96724e7fcbe0bed632130bb72631f53192753f5 (diff)
WinGui: Agressively call global_close on libhb to attempt to make sure temporary directories are cleared up. Should fix #3154 where the worker proces isn't fully clearing up behind itself.
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrake.Worker/Program.cs14
-rw-r--r--win/CS/HandBrake.Worker/Routing/ApiRouter.cs4
-rw-r--r--win/CS/HandBrakeWPF/App.xaml.cs14
3 files changed, 22 insertions, 10 deletions
diff --git a/win/CS/HandBrake.Worker/Program.cs b/win/CS/HandBrake.Worker/Program.cs
index 355ac6d46..7d6d4ebc3 100644
--- a/win/CS/HandBrake.Worker/Program.cs
+++ b/win/CS/HandBrake.Worker/Program.cs
@@ -14,6 +14,7 @@ namespace HandBrake.Worker
using System.Net;
using System.Threading;
+ using HandBrake.Interop.Interop;
using HandBrake.Worker.Routing;
public class Program
@@ -23,6 +24,8 @@ namespace HandBrake.Worker
public static void Main(string[] args)
{
+ AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
+
int port = 8037; // Default Port;
string token = null;
@@ -45,18 +48,18 @@ namespace HandBrake.Worker
}
}
}
-
+
Console.WriteLine("Worker: Starting HandBrake Engine ...");
router = new ApiRouter();
router.TerminationEvent += Router_TerminationEvent;
-
+
Console.WriteLine("Worker: Starting Web Server on port {0} ...", port);
Dictionary<string, Func<HttpListenerRequest, string>> apiHandlers = RegisterApiHandlers();
HttpServer webServer = new HttpServer(apiHandlers, port, token);
if (webServer.Run())
{
Console.WriteLine("Worker: Server Started");
- manualResetEvent.WaitOne();webServer.Stop();
+ manualResetEvent.WaitOne();
webServer.Stop();
}
else
@@ -65,6 +68,11 @@ namespace HandBrake.Worker
}
}
+ private static void CurrentDomain_ProcessExit(object sender, System.EventArgs e)
+ {
+ HandBrakeUtils.DisposeGlobal();
+ }
+
private static Dictionary<string, Func<HttpListenerRequest, string>> RegisterApiHandlers()
{
Dictionary<string, Func<HttpListenerRequest, string>> apiHandlers =
diff --git a/win/CS/HandBrake.Worker/Routing/ApiRouter.cs b/win/CS/HandBrake.Worker/Routing/ApiRouter.cs
index 3b7b46b6a..5eced8712 100644
--- a/win/CS/HandBrake.Worker/Routing/ApiRouter.cs
+++ b/win/CS/HandBrake.Worker/Routing/ApiRouter.cs
@@ -11,7 +11,6 @@
namespace HandBrake.Worker.Routing
{
using System;
- using System.Collections.Generic;
using System.Net;
using HandBrake.Interop.Interop;
@@ -19,7 +18,6 @@ namespace HandBrake.Worker.Routing
using HandBrake.Interop.Utilities;
using HandBrake.Worker.Logging;
using HandBrake.Worker.Logging.Interfaces;
- using HandBrake.Worker.Logging.Models;
using HandBrake.Worker.Routing.Commands;
using HandBrake.Worker.Routing.Results;
using HandBrake.Worker.Utilities;
@@ -148,6 +146,8 @@ namespace HandBrake.Worker.Routing
this.completedState = new JsonState() { WorkDone = new WorkDone() { Error = e.Error } };
this.completedState.State = "WORKDONE";
this.logHandler.ShutdownFileWriter();
+ this.handbrakeInstance.Dispose();
+ HandBrakeUtils.DisposeGlobal();
}
private void Initialise(InitCommand command)
diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs
index 2269162a2..a7c0fad9a 100644
--- a/win/CS/HandBrakeWPF/App.xaml.cs
+++ b/win/CS/HandBrakeWPF/App.xaml.cs
@@ -22,7 +22,6 @@ namespace HandBrakeWPF
using HandBrake.Interop.Interop;
- using HandBrakeWPF.Helpers;
using HandBrakeWPF.Instance;
using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Interfaces;
@@ -31,7 +30,7 @@ namespace HandBrakeWPF
using HandBrakeWPF.ViewModels;
using HandBrakeWPF.ViewModels.Interfaces;
- using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
+ using GeneralApplicationException = Exceptions.GeneralApplicationException;
/// <summary>
/// Interaction logic for App.xaml
@@ -44,9 +43,9 @@ namespace HandBrakeWPF
public App()
{
Application.Current.Dispatcher.UnhandledException += this.Dispatcher_UnhandledException;
- AppDomain.CurrentDomain.UnhandledException +=
- this.CurrentDomain_UnhandledException;
-
+ AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException;
+ AppDomain.CurrentDomain.ProcessExit += this.CurrentDomain_ProcessExit;
+
ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(15000));
}
@@ -160,6 +159,11 @@ namespace HandBrakeWPF
}
}
+ private void CurrentDomain_ProcessExit(object sender, System.EventArgs e)
+ {
+ HandBrakeUtils.DisposeGlobal();
+ }
+
/// <summary>
/// Non-UI Thread exception handler.
/// </summary>