private IResult InstallUpdates(IUpdateSession3 session, UpdateCollection updates) { IInstallationJob installJob = null; try { SetPreInstallTitle(); SetPreInstallText(); var installer = session.CreateUpdateInstaller(); installer.Updates = updates; installer.AllowSourcePrompts = false; installer.IsForced = true; installer.ClientApplicationID = AppearanceManager.ApplicationTitle; var displayManager = new UpdateDisplayManager( SettingsManager, AppearanceManager, ProgressTextOutputKey, InstallProgressText, ProgressTitleOutputKey, InstallProgressTitle, DeferTitleUpdates, DeferTextUpdates); if (string.IsNullOrWhiteSpace(ProgressTextOutputKey)) displayManager = null; if (string.IsNullOrWhiteSpace(InstallProgressText)) displayManager = null; installJob = installer.BeginInstall(displayManager, displayManager, null); SetCreepTimer(displayManager); while (!installJob.IsCompleted) { System.Threading.Thread.Sleep(5); Application.Current.DoEvents(); if (DialogsManager.CancelRequested) { installJob.RequestAbort(); } } var result = installer.EndInstall(installJob); SetInstalledUpdatesObject(result, updates); LogInstallResult(updates, result); return ConvertToResult(result, updates); } catch (Exception e) { return new ExceptionOccurred(e); } finally { if (installJob != null) installJob.CleanUp(); ClearCreepTimer(); } }
private void SetCreepTimer(UpdateDisplayManager updateDisplayManager) { if (!UseCreepTimer) return; if (CreepInterval < 1) return; if (CreepLimit == 0) CreepLimit = 100; _timer = new DispatcherTimer {Interval = new TimeSpan(0, 0, CreepInterval)}; _currentDisplayManager = updateDisplayManager; _timer.Tick += _timer_Tick; _timer.IsEnabled = true; }
private IResult DownloadUpdates(IUpdateSession3 session, UpdateCollection updates) { IDownloadJob downloadJob = null; try { var downloader = session.CreateUpdateDownloader(); downloader.Updates = updates; downloader.Priority = DownloadPriority.dpHigh; downloader.IsForced = true; downloader.ClientApplicationID = AppearanceManager.ApplicationTitle; var displayManager = new UpdateDisplayManager( SettingsManager, AppearanceManager, ProgressTextOutputKey, DownloadProgressText, ProgressTitleOutputKey, DownloadProgressTitle, DeferTitleUpdates, DeferTextUpdates); if (string.IsNullOrWhiteSpace(ProgressTextOutputKey)) displayManager = null; if (string.IsNullOrWhiteSpace(InstallProgressText)) displayManager = null; downloadJob = downloader.BeginDownload(displayManager, displayManager, null); while (!downloadJob.IsCompleted) { System.Threading.Thread.Sleep(5); Application.Current.DoEvents(); if (DialogsManager.CancelRequested) { downloadJob.RequestAbort(); } } var result = downloader.EndDownload(downloadJob); LogDownloadResults(updates, result); return ConvertToResult(result); } catch (Exception e) { return new ExceptionOccurred(e); } finally { if (downloadJob != null) downloadJob.CleanUp(); } }