private async void InitApp() { if ((await PurposeHelper.ConfirmPurpose()) == false) { return; } InitNotifyIcon(); System.Windows.Application.Current.Deactivated += Application_Deactivated; #if SQUIRREL updateTimer = new DispatcherTimer() { Interval = TimeSpan.FromMinutes(30), }; updateTimer.Tick += UpdateTimer_Tick; checkForStoreVersionTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(5), }; checkForStoreVersionTimer.Tick += CheckForStoreVersionTimer_Tick; #endif CheckAccountId(true); #if !SQUIRREL ApplicationRestart.RegisterForRestart(); #endif if (Properties.Settings.Default.HasLastExceptionMessage) { var exceptionMessage = Properties.Settings.Default.LastExceptionMessage ?? "null"; Properties.Settings.Default.HasLastExceptionMessage = false; Properties.Settings.Default.LastExceptionMessage = ""; Properties.Settings.Default.Save(); #if !DEBUG AutoMeasurement.Client.TrackEvent("UnhandledException", "Fatal", exceptionMessage); #endif } #if !SQUIRREL Settings.Save(); #endif var currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); if (processes.Length > 1) { var otherProcess = processes.Where(p => p.Id != currentProcess.Id && p.MainModule.FileName != currentProcess.MainModule.FileName).FirstOrDefault(); if (otherProcess != null) { #if SQUIRREL //Store version is running, so I'll open roamit and close myself Process.Start("roamit://"); notifyIcon.Visible = false; System.Windows.Application.Current.Shutdown(); #else //Close squirrel version of the app, if running otherProcess.CloseApp(); #endif } } }
private void OnApplicationRestart() { ApplicationRestart?.Invoke(this, EventArgs.Empty); }