private void InstallUpdates() { iUpdateThread = new Thread(new ThreadStart(() => { iAutoUpdate.DownloadUpdate(iInfo); Dispatcher.Invoke((Action) delegate() { if (!iClosed) { progressBar.Visibility = Visibility.Visible; btnClose.IsEnabled = false; } }); if (iAutoUpdate.ApplyUpdate(iInfo)) { Dispatcher.Invoke((Action) delegate() { if (!iClosed) { DialogResult = true; Close(); } }); } else { Dispatcher.Invoke((Action) delegate() { if (!iClosed) { txtStatus.Text = "Failed to apply update. Check user log for further info."; btnClose.IsEnabled = true; } }); } iUpdateThread = null; })); iUpdateThread.Name = "Update"; iUpdateThread.IsBackground = true; iAutoUpdate.EventUpdateProgress += UpdateProgress; iAutoUpdate.EventUpdateFailed += UpdateFailed; iUpdateThread.Start(); }
private void Run() { iAutoUpdate.DownloadUpdate(iInfo); Invoke((MethodInvoker) delegate() { buttonCancel.Enabled = false; }); if (iAutoUpdate.ApplyUpdate(iInfo)) { Invoke((MethodInvoker) delegate() { DialogResult = DialogResult.OK; Close(); }); } }