diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-17 15:52:11 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-02-17 15:52:11 +0200 |
| commit | e29d962c5602fc9fc3a54fa4da8957609de7eea4 (patch) | |
| tree | 857c8448611b79c3d3834f37edb00965ad5435ba /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication | |
| parent | 0cd0b590f62b31a8874ea21f225ba75c7a37053c (diff) | |
| download | Tango-e29d962c5602fc9fc3a54fa4da8957609de7eea4.tar.gz Tango-e29d962c5602fc9fc3a54fa4da8957609de7eea4.zip | |
Completed PPC watchdog !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 39ce8cd30..43b0cc047 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -27,6 +27,7 @@ using System.Diagnostics; using Tango.PPC.Common.EventLogging; using Tango.BL.Enumerations; using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.WatchDog; namespace Tango.PPC.UI.PPCApplication { @@ -44,6 +45,7 @@ namespace Tango.PPC.UI.PPCApplication private IEventLogger _eventLogger; private IPPCModuleLoader _moduleLoader; private INotificationProvider _notificationProvider; + private WatchDogServer _watchdogServer; /// <summary> /// Occurs when a system restart is required. @@ -157,6 +159,14 @@ namespace Tango.PPC.UI.PPCApplication LogManager.Log(settings.ToJsonString()); + //Start watchdog + _watchdogServer = new WatchDogServer(Application.Current.Dispatcher); + + if (settings.EnableWatchDog) + { + _watchdogServer.Start(); + } + LogManager.Log("Reading Core settings..."); var coreSettings = SettingsManager.Default.GetOrCreate<CoreSettings>(); @@ -323,16 +333,23 @@ namespace Tango.PPC.UI.PPCApplication /// </summary> public void ShutDown() { - //TODO: Needs some work on logging and shutdown procedures! Do I really need this? - - LogManager.Log("Shutting down application..."); + if (IsShuttingDown) return; IsShuttingDown = true; - foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + try { - vm.OnApplicationShuttingDown(); + LogManager.Log("Shutting down application..."); + _watchdogServer.Dispose(); + + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + { + vm.OnApplicationShuttingDown(); + } } + catch { } + + Environment.Exit(0); } /// <summary> @@ -340,6 +357,23 @@ namespace Tango.PPC.UI.PPCApplication /// </summary> public void Restart() { + if (IsShuttingDown) return; + + IsShuttingDown = true; + + try + { + LogManager.Log("Restarting the application..."); + + _watchdogServer.Dispose(); + + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + { + vm.OnApplicationShuttingDown(); + } + } + catch { } + Process.Start(Application.ResourceAssembly.Location); Environment.Exit(0); } |
