/// <summary> /// If we have a valid release and it is later than the current running release /// then display the Upgrade dialog. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void DoWorkCompleted(object sender, RunWorkerCompletedEventArgs e) { UpgradeRelease release = e.Result as UpgradeRelease; if (release == null) { isRunning = false; if (isUserInvoked) { isUserInvoked = false; MessageWindow.Show( Resx.NoUpdateConnection, Resx.I_ApplicationTitle, MessageBoxButton.OK, MessageWindowImage.OK); } return; } if (!release.Dispatcher.CheckAccess()) { release.Dispatcher.BeginInvoke((Action) delegate { DoWorkCompleted(sender, e); }); return; } if (release.IsUpgradeAvailable) { Logger.WriteLine(Logger.Level.Info, "Upgrade", $"Upgrade is available, {release.CurrentVersion} -> {release.ReleaseVersion}"); isRunning = false; UpgradeWindow dialog = new UpgradeWindow(release); dialog.ShowDialog(); } else if (isUserInvoked) { Logger.WriteLine(Logger.Level.Info, "Upgrade", $"Upgrade is not available for {release.CurrentVersion}"); isRunning = false; isUserInvoked = false; MessageWindow.Show( Resx.NoUpgrades, Resx.I_ApplicationTitle, MessageBoxButton.OK, MessageWindowImage.OK); } else { Logger.WriteLine(Logger.Level.Info, "Upgrade", $"Running version {release.CurrentVersion}"); isRunning = false; } }
/// <summary> /// If we have a valid release and it is later than the current running release /// then display the Upgrade dialog. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void DoWorkCompleted (object sender, RunWorkerCompletedEventArgs e) { Logger.WriteLine(Logger.Level.Info, "Upgrade", "Work completed"); UpgradeRelease release = e.Result as UpgradeRelease; if (release == null) { isRunning = false; if (isUserInvoked) { isUserInvoked = false; MessageWindow.Show( Resx.NoUpdateConnection, Resx.ApplicationTitle, MessageBoxButton.OK, MessageWindowImage.OK); } return; } if (!release.Dispatcher.CheckAccess()) { release.Dispatcher.BeginInvoke((Action)delegate { DoWorkCompleted(sender, e); }); return; } if (release.IsUpgradeAvailable) { Logger.WriteLine(Logger.Level.Info, "Upgrade", "Upgrade is available"); isRunning = false; UpgradeWindow dialog = new UpgradeWindow(release); bool result = (bool)dialog.ShowDialog(); dialog = null; } else if (isUserInvoked) { Logger.WriteLine(Logger.Level.Info, "Upgrade", "Upgrade is not available"); isRunning = false; isUserInvoked = false; MessageWindow.Show( Resx.NoUpgrades, Resx.ApplicationTitle, MessageBoxButton.OK, MessageWindowImage.OK); } else { isRunning = false; } }