Process proc = new Process(); proc .StartInfo.FileName = strScript; proc .StartInfo.WorkingDirectory = strDirectory; proc .StartInfo.CreateNoWindow = true; proc .StartInfo.UseShellExecute = false; proc .StartInfo.RedirectStandardOutput = true; proc .Start(); |
eventOutput = new AutoResetEvent(false); AutoResetEvent[] events = new AutoResetEvent[1]; events[0] = m_eventOutput; m_threadOutput = new Thread( new ThreadStart( DisplayOutput ) ); m_threadOutput.Start(); WaitHandle.WaitAll( events ); |
private void DisplayOutput() { while ( m_procScript != null && !m_procScript.HasExited ) { string strLine = null; while ( ( strLine = m_procScript.StandardOutput.ReadLine() ) != null) { m_txtOutput.AppendText( strLine + "\r\n" ); m_txtOutput.SelectionStart = m_txtOutput.Text.Length; m_txtOutput.ScrollToCaret(); } Thread.Sleep( 100 ); } m_eventOutput.Set(); } |
m_txtOutput.AppendText( strLine + "\r\n" ); m_txtOutput.SelectionStart = m_txtOutput.Text.Length; m_txtOutput.ScrollToCaret(); |