/// <summary> /// Event called when the exit button is pressed, starts a new thread to shutdown the application (this is so the dispatcher is not /// responsible for this) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExitApplication(object sender, RoutedEventArgs e) { ThreadPool.QueueUserWorkItem(state => { Hide(); _appContext.Shutdown(); }); // Thread shutdownThread = new Thread(_appContext.Shutdown) { IsBackground = true, Name = "shutdownByUserThread" }; // shutdownThread.Start(); }
public void RunTask() { try { var regVersion = _appContext.Reg.getRegValue("Version", true); //Logger.Debug("Checking for agent upgrade " + _appContext.StartupVersion + " vs " + regVersion); if (new Version(regVersion).CompareTo(new Version(_appContext.StartupVersion)) > 0) { Logger.Info("My file version has changed " + _appContext.StartupVersion + " => " + regVersion + ", closing to re-open as new version."); try { //if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Gwupe.Upgrade.exe")) //{ Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Gwupe.Upgrade.exe"); /*} * else * { * //Fallback * Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + * "\\BlitsMe.Agent.Upgrade.exe"); * }*/ } catch (Exception e) { Logger.Error("Failed to start the upgrade exe, but will stop myself anyway.", e); } _appContext.Shutdown(); } } catch (Exception e) { Logger.Error("Failed to check version and act : " + e.Message, e); } }
private void exitItem_Click(object sender, EventArgs e) { _appContext.Shutdown(); }