I'm trying to do console output in RichTextBox
. Here is my code:
public void Run() { Process myProcess = new Process(); myProcess.StartInfo.FileName = @"start.bat"; myProcess.StartInfo.CreateNoWindow = true; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardOutput = true; myProcess.OutputDataReceived += proc_OutputDataReceived; myProcess.Start(); myProcess.BeginOutputReadLine(); } public void proc_OutputDataReceived(object sender, DataReceivedEventArgs e) { this.Invoke(new Action(() => richTextBoxConsole.Text += (e.Data + Environment.NewLine))); }
But in RichTextBox
, only the first line from the console is displayed. And It is necessary to display all the lines in real time. Where is the mistake?
richTextBoxConsole.Text +=
UserichTextBoxConsole.AppendText()
- Sublihim