diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-25 00:36:01 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-25 00:36:01 +0200 |
| commit | 24bc7677e625a6f6535cd473362e50939da532a1 (patch) | |
| tree | 99eac20ee69cedd86e56406da7fd11d195e91b78 /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | |
| parent | 9947803e9b41d32ca60e4f9d8d6ff67a7aa80624 (diff) | |
| download | Tango-24bc7677e625a6f6535cd473362e50939da532a1.tar.gz Tango-24bc7677e625a6f6535cd473362e50939da532a1.zip | |
Improved PPC update finalization procedure before restart.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | 67 |
1 files changed, 60 insertions, 7 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 2ca191d01..af3473a98 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -513,7 +513,11 @@ namespace Tango.PPC.UI.PPCApplication foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) { - vm.OnApplicationShuttingDown(); + try + { + vm.OnApplicationShuttingDown(); + } + catch { } } } catch { } @@ -549,23 +553,58 @@ namespace Tango.PPC.UI.PPCApplication IsShuttingDown = true; + LogManager.Log("Restarting application for update..."); + try { - _watchdogServer.Dispose(); + LogManager.Log("Navigating to restart view..."); + _dispatcher.Invoke(() => + { + var nav = TangoIOC.Default.GetInstance<INavigationManager>(); + if (nav != null) + { + nav.NavigateTo(NavigationView.RestartingView); + } + }); + LogManager.Log("Waiting 2 seconds..."); + await Task.Delay(2000); + + try + { + LogManager.Log("Disposing watch dog..."); + _watchdogServer.Dispose(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disposing watch dog."); + } + + LogManager.Log("Raising OnApplicationShutDown for all view models..."); foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) { - vm.OnApplicationShuttingDown(); + try + { + vm.OnApplicationShuttingDown(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error on {vm.GetType().Name}.OnApplicationShutDown()."); + } } } catch { } try { + LogManager.Log("Saving application settings..."); SettingsManager.Default.GetOrCreate<PPCSettings>().PreviousApplicationVersion = Version.ToString(); SettingsManager.Default.Save(); } - catch { } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving application settings."); + } try { @@ -667,23 +706,37 @@ namespace Tango.PPC.UI.PPCApplication private Task FinalizeApplication() { + LogManager.Log("Finalizing application..."); + return LimitedTimeTask.StartNew(() => { try { + LogManager.Log("Flushing machine events..."); _eventLogger.Log(EventTypes.APPLICATION_TERMINATED, "User Interface Terminated."); _eventLogger.FlushAll(); } - catch { } + catch (Exception ex) + { + LogManager.Log(ex, "Error flushing machine events."); + } try { + LogManager.Log("Disposing insights manager (max 40 seconds to complete)..."); + Stopwatch watch = new Stopwatch(); + watch.Start(); var frame = InsightsFrame.CreateEmpty(DateTime.UtcNow); InsightsManager.Default.InsertFrame(frame); InsightsManager.Default.Dispose(); + watch.Stop(); + LogManager.Log($"Insights manager disposed after {(int)watch.Elapsed.TotalSeconds} seconds."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disposing insights manager."); } - catch { } - }, TimeSpan.FromSeconds(20)); + }, TimeSpan.FromSeconds(40)); } } } |
