private void UpdateUI(object sender, InstallerProgressEvent e) { if (e.Message.Length > 0) { logTextBox.AppendText(e.Message + Environment.NewLine); logTextBox.SelectionStart = logTextBox.Text.Length; logTextBox.SelectionLength = 0; } installProgressBar.Value = e.PercentDone; if (e.PercentDone == installProgressBar.Maximum) { cancelButton.Visible = false; closeButton.Visible = true; } }
public void ShowProgress(string message, int percentDone) { if (InvokeRequired) { // Wrap the parameters in some EventArgs-derived custom class: System.EventArgs e = new InstallerProgressEvent(message, percentDone); object[] pList = { this, e }; // Invoke the method. This class is derived // from Form, so we can just call BeginInvoke // to get to the UI thread. BeginInvoke(new MyProgressEventsHandler(UpdateUI), pList); } else { // We're already on the UI thread just // call straight through. UpdateUI(this, new InstallerProgressEvent(message, percentDone)); } }