/// <summary> /// Synchronously update /// </summary> /// <returns>The result of the upgrade operation</returns> private UpdateResult Update() { // Reset here; in case anything goes wrong in the Interim, the value will reflect that. _updateStopwatch.Restart(); try { WaitForInitializationToComplete(); // Short-circuit updates that don't make sense if (UpdateOptionAsync.Result != AutoUpdateOption.OptionalUpgrade && UpdateOptionAsync.Result != AutoUpdateOption.RequiredUpgrade) { return(UpdateResult.NoUpdateAvailable); } VersionSwitcherWrapper.InstallUpgrade(_installerUri); return(UpdateResult.Success); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); } #pragma warning restore CA1031 // Do not catch general exception types finally { _updateStopwatch.Stop(); } return(UpdateResult.Unknown); }
private async Task <bool> HandleReleaseSwitch() { var channelDialog = new ChangeChannelContainedDialog(appSettingsCtrl.SelectedReleaseChannel); if (appSettingsCtrl.SelectedReleaseChannel == Configuration.ReleaseChannel || !await MainWin.ctrlDialogContainer.ShowDialog(channelDialog).ConfigureAwait(false)) { return(false); } try { VersionSwitcherWrapper.ChangeChannel(appSettingsCtrl.SelectedReleaseChannel); Dispatcher.Invoke(() => MainWin.Close()); return(true); } catch (Exception ex) { ex.ReportException(); Dispatcher.Invoke(() => MessageDialog.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ConfigurationModeControl_VersionSwitcherException)) ); } return(false); }
private async Task <bool> HandleReleaseSwitch() { if (appSettingsCtrl.SelectedReleaseChannel == Configuration.ReleaseChannel) { return(false); } Logger.PublishTelemetryEvent(TelemetryEventFactory.ForReleaseChannelChangeConsidered( Configuration.ReleaseChannel, appSettingsCtrl.SelectedReleaseChannel)); var channelDialog = new ChangeChannelContainedDialog(appSettingsCtrl.SelectedReleaseChannel); if (!await MainWin.ctrlDialogContainer.ShowDialog(channelDialog).ConfigureAwait(false)) { return(false); } // If the window is topmost, the UAC prompt from the version switcher will appear behind the main window. // To prevent this, save the previous topmost state, ensure that the main window is not topmost when the // UAC prompt will display, then restore the previous topmost state. bool previousTopmostSetting = Configuration.AlwaysOnTop; try { Dispatcher.Invoke(() => { previousTopmostSetting = MainWin.Topmost; MainWin.Topmost = false; }); VersionSwitcherWrapper.ChangeChannel(appSettingsCtrl.SelectedReleaseChannel); Dispatcher.Invoke(() => MainWin.Close()); return(true); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); Dispatcher.Invoke(() => { MainWin.Topmost = previousTopmostSetting; MessageDialog.Show(Properties.Resources.ConfigurationModeControl_VersionSwitcherException); }); return(false); } #pragma warning restore CA1031 // Do not catch general exception types }