/// <summary> /// Download updates async /// </summary> /// <param name="uCollection"></param> public void DownloadUpdates(UpdateCollection uCollection) { updateDownloader = new UpdateDownloader(); progressWindow = new ProgressWindow(); progressWindow.Show(); progressWindow.Title = "Downloading..."; downloadJob = null; updateDownloader.Updates = uCollection; downloadJob = updateDownloader.BeginDownload(new DownloadProgressChangedFunc(this), new DownloadCompletedFunc(this), null); InstallButton.IsEnabled = false; }
/// <summary> /// Install all downloaded updates /// Auto accept Eula /// </summary> public void BeginInstallation() { progressWindow = new ProgressWindow(); progressWindow.Show(); progressWindow.Title = "Installation..."; installationJob = null; installCollection = new UpdateCollection(); foreach (IUpdate update in this.sResult.Updates) { if (update.IsDownloaded) { //testen ob das funktioniert update.AcceptEula(); } // update.InstallationBehavior.RebootBehavior installCollection.Add(update); } installer = uSession.CreateUpdateInstaller(); installer.Updates = installCollection; installationJob = installer.BeginInstall(new InstallProgressChangedFunc(this), new InstallCompletedFunc(this), null); }
private void Update_Click(object sender, RoutedEventArgs e) { // Set the temp file name and create new 0-byte file TempFilePath = Path.GetTempFileName(); progressWindow = new ProgressWindow(); progressWindow.Topmost = true; progressWindow.Show(); // Set up WebClient to download file webClient = new WebClient(); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); // Set up backgroundworker to hash file bgWorker = new BackgroundWorker(); bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork); bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_RunWorkerCompleted); // Download file try { webClient.DownloadFileAsync(updateInfo.Uri, TempFilePath); } catch (Exception ex) { LogWriter.LogWrite("Application updated failed: " + ex.ToString()); Close(); } }