3
Reply

How to write to console app with hidden window

Poppa Wallace

Poppa Wallace

Dec 20 2016 8:03 AM
297
  1. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)  
  2.         {  
  3.             _process = new Process();  
  4.             _process.StartInfo.FileName = @"//myconsolaeapp";  
  5.             _process.StartInfo.UseShellExecute = false;  
  6.             _process.EnableRaisingEvents = true;  
  7.             _process.StartInfo.CreateNoWindow = true;  
  8.             _process.StartInfo.RedirectStandardOutput = true;  
  9.             _process.OutputDataReceived += OutputHandler;  
  10.             //_process.Exited += (ErrorHandler);  
  11.             _process.SynchronizingObject = richTextBox1;  
  12.             _process.SynchronizingObject = richTextBox1;  
  13.             _process.Start();  
  14.             _process.BeginOutputReadLine();  
  15.             _process.WaitForExit();  
  16.         }  
and other methods 
 
  1. private void OutputHandler(Object source, DataReceivedEventArgs outLine)  
  2.        {  
  3.              
  4.            if (!String.IsNullOrEmpty(outLine.Data))  
  5.            {  
  6.                richTextBox1.AppendText(outLine.Data + "\r\n");  
  7.                richTextBox1.ScrollToCaret();  
  8.                
  9.            }  
  10.        }  
 I have a textbox that once text is changed it is written to my hidden console window and updated in the tichtextbox1.
 
Can anybody give me some hints please
 
 

Answers (3)