private void backgroundWorker1_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e) { progressBar1.Value += 1; TxtConsole.AppendText(e.UserState as string + Environment.NewLine); TxtConsole.SelectionStart = TxtConsole.Text.Length; TxtConsole.ScrollToCaret(); }
public void AddLine(string line, Color color) { try { TxtConsole.BeginInvoke( new Action(() => { TxtConsole.SelectionColor = color; TxtConsole.AppendText(line + "\n"); TxtConsole.ScrollToCaret(); } )); } catch (Exception) { } }
private void backgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (e.Cancelled) { TxtConsole.AppendText("Process was cancelled" + Environment.NewLine); } else if (e.Error != null) { TxtConsole.AppendText("There was an error running the process. The thread aborted" + Environment.NewLine); } else { TxtConsole.AppendText("Process was completed" + Environment.NewLine); } setEnableOnOff(true); TxtConsole.SelectionStart = TxtConsole.Text.Length; TxtConsole.ScrollToCaret(); }