public static void Shutdown(bool errorShutdown = false) { if (Configuration.SendTelemetry && Telemetry.UseApplicationInsights && AppInsights != null) { var t = AppRunTelemetry.Telemetry; t.Properties.Add("usage", Configuration.ApplicationUpdates.AccessCount.ToString()); t.Properties.Add("registered", UnlockKey.IsRegistered().ToString()); t.Properties.Add("version", GetVersion()); t.Properties.Add("dotnetversion", ComputerInfo.GetDotnetVersion()); t.Stop(); try { AppInsights.StopOperation(AppRunTelemetry); } catch (Exception ex) { LogToLogfile("Failed to Stop Telemetry Client: " + ex.GetBaseException().Message); } AppInsights.Flush(); AppInsights = null; } else { SendTelemetry("shutdown"); } }
private void HandleWindowClosing(Window win, bool hideOnWindowClose) { win.Closing += async(s, e) => { e.Cancel = true; if (hideOnWindowClose) { win.Hide(); AppInsights.Post($"Hiding “{CaptionPrefix}” instead of closing it"); AppInsights.Flush(); } else { AppInsights.Post($"Closing “{CaptionPrefix}”"); await ExitCmd.RunAsync(); } }; win.IsVisibleChanged += (s, e) => { if (win.Visibility == Visibility.Visible) { _onWindowShown.Raise(); } else { _onWindowHidden.Raise(); } }; }
public static void Shutdown(bool errorShutdown = false) { if (Configuration.SendTelemetry && Telemetry.UseApplicationInsights && AppInsights != null) { var t = AppRunTelemetry.Telemetry; // multi-instance shutdown - ignore if (t.Properties.ContainsKey("usage")) { return; } t.Properties.Add("usage", Configuration.ApplicationUpdates.AccessCount.ToString()); t.Properties.Add("registered", UnlockKey.IsRegistered().ToString()); t.Properties.Add("version", GetVersion()); t.Properties.Add("dotnetversion", WindowsUtils.GetDotnetVersion()); t.Properties.Add("culture", CultureInfo.CurrentUICulture.IetfLanguageTag); t.Stop(); try { AppInsights.StopOperation(AppRunTelemetry); } catch (Exception ex) { LogLocal("Failed to Stop Telemetry Client: " + ex.GetBaseException().Message); } AppInsights.Flush(); AppInsights = null; AppRunTelemetry.Dispose(); } else { SendTelemetry("shutdown"); } var tempPath = Path.GetTempPath(); // Cleanup temp files File.Delete(Path.Combine(tempPath, "_MarkdownMonster_Preview.html")); FileUtils.DeleteTimedoutFiles(Path.Combine(tempPath, "mm_diff_*.*"), 1); }
private async Task ExitApp(bool relaunchAfter) { try { OnWindowClose(); await OnWindowCloseAsync(); _scope?.Dispose(); AppInsights.Flush(); if (relaunchAfter) { CurrentExe.RelaunchApp(); } else { CurrentExe.Shutdown(); } } catch { } }