private void updateCheck_Complete(object sender, RunWorkerCompletedEventArgs e) { var exTrust = e.Result as TrustNotGrantedException; if (exTrust != null) { if (ShowUpgradeForm(AppDeployment.GetVersionFromUpdateLocation(), false, true)) { AppDeployment.OpenInstallLink(ParentWindow); } return; } var ex = e.Result as Exception; if (ex != null) { // Show an error message box to allow a user to inspect the exception stack trace MessageDlg.ShowWithException(ParentWindow, Resources.UpgradeManager_updateCheck_Complete_Failed_attempting_to_check_for_an_upgrade_, ex); // Show no upgrade found message to allow a user to turn off or on this checking ShowUpgradeForm(null, false, false); return; } _updateInfo = e.Result as UpdateCheckDetails; if (_updateInfo != null && _updateInfo.UpdateAvailable) { if (!ShowUpgradeForm(_updateInfo.AvailableVersion, true, true)) { return; } using (var longWaitUpdate = new LongWaitDlg { Text = string.Format(Resources.UpgradeManager_updateCheck_Complete_Upgrading__0_, Program.Name), Message = GetProgressMessage(0, _updateInfo.UpdateSizeBytes ?? 0), ProgressValue = 0 }) { longWaitUpdate.PerformWork(ParentWindow, 500, broker => { BeginUpdate(broker); _endUpdateEvent.WaitOne(); _endUpdateEvent.Dispose(); broker.ProgressValue = 100; }); } if (_completeArgs == null || _completeArgs.Cancelled) { return; } if (_completeArgs.Error != null) { MessageDlg.ShowWithException(ParentWindow, Resources.UpgradeManager_updateCheck_Complete_Failed_attempting_to_upgrade_, _completeArgs.Error); if (ShowUpgradeForm(null, false, true)) { AppDeployment.OpenInstallLink(ParentWindow); } return; } AppDeployment.Restart(); } else if (!_startup) { ShowUpgradeForm(null, false, false); } }