/// <summary> /// Download the upgrade installer and close the app depending on if it is successful or not /// </summary> private async void DownLoadInstaller(IAutoUpdate autoUpdate, AutoUpdateOption updateOption) { UpdateResult result = UpdateResult.Unknown; // 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 = Topmost; try { ctrlProgressRing.Activate(); Topmost = false; result = await autoUpdate.UpdateAsync().ConfigureAwait(true); Logger.PublishTelemetryEvent(TelemetryAction.Upgrade_DoInstallation, new Dictionary <TelemetryProperty, string> { { TelemetryProperty.UpdateInstallerUpdateTime, GetTimeSpanTelemetryString(autoUpdate.GetUpdateTime()) }, { TelemetryProperty.UpdateResult, updateOption.ToString() }, }); if (result == UpdateResult.Success) { this.Close(); return; } } #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 Topmost = previousTopmostSetting; ctrlProgressRing.Deactivate(); Logger.PublishTelemetryEvent(TelemetryAction.Upgrade_InstallationError, TelemetryProperty.Error, result.ToString()); string message = updateOption == AutoUpdateOption.RequiredUpgrade ? GetMessageForRequiredUpdateFailure() : GetMessageForOptionalUpdateFailure(); MessageDialog.Show(message); if (updateOption == AutoUpdateOption.RequiredUpgrade) { this.Close(); return; } }
/// <summary> /// Download the upgrade installer and close the app depending on if it is successful or not /// </summary> private async void DownLoadInstaller(IAutoUpdate autoUpdate, AutoUpdateOption updateOption) { UpdateResult result = UpdateResult.Unknown; try { ctrlProgressRing.Activate(); result = await autoUpdate.UpdateAsync().ConfigureAwait(true); Logger.PublishTelemetryEvent(TelemetryAction.Upgrade_DoInstallation, new Dictionary <TelemetryProperty, string> { { TelemetryProperty.UpdateInstallerDownloadTime, GetTimeSpanTelemetryString(autoUpdate.GetInstallerDownloadTime()) }, { TelemetryProperty.UpdateInstallerVerificationTime, GetTimeSpanTelemetryString(autoUpdate.GetInstallerVerificationTime()) }, { TelemetryProperty.UpdateResult, updateOption.ToString() }, }); if (result == UpdateResult.Success) { this.Close(); return; } } catch (Exception) { }; ctrlProgressRing.Deactivate(); Logger.PublishTelemetryEvent(TelemetryAction.Upgrade_InstallationError, TelemetryProperty.Error, result.ToString()); string message = updateOption == AutoUpdateOption.RequiredUpgrade ? GetMessageForRequiredUpdateFailure(result) : GetMessageForOptionalUpdateFailure(result); MessageBox.Show(message); if (updateOption == AutoUpdateOption.RequiredUpgrade) { this.Close(); return; } }