C# 클래스 Twinspire.ProcessIoManager

Class that manages the reading of the output produced by a given 'Process' and reports the output via events. Both standard error (stderr) and standard output (stdout) are managed and reported. The stdout and stderr monitoring and reading are each performed by separate background threads. Each thread blocks on a Read() method, waiting for text in the stream being monitored to become available. Note the Process.RedirectStandardOutput must be set to true in order to read standard output from the process, and the Process.RedirectStandardError must be set to true to read standard error.
파일 보기 프로젝트 열기: twinspire/twinspire 1 사용 예제들

공개 메소드들

메소드 설명
ProcessIoManager ( Process process ) : System

Initializes a new instance of the ProcessIoManager class.

Does not automatically start listening for stdout/stderr. Call StartProcessOutputRead() to begin listening for process output.

StartProcessOutputRead ( ) : void

Starts the background threads reading any output produced (standard output, standard error) that is produces by the running process.

StopMonitoringProcessOutput ( ) : void

Stops both the standard input and stardard error background reader threads (via the Abort() method)

WriteStdin ( string text ) : void

Writes the supplied text string to the standard input (stdin) of the running process

In order to be able to write to the Process, the StartInfo.RedirectStandardInput must be set to true.

비공개 메소드들

메소드 설명
CheckForValidProcess ( string errorMessageText, bool checkForHasExited ) : void

Checks for valid (non-null Process), and optionally check to see if the process has exited. Throws Exception if process is null, or if process has existed and checkForHasExited is true.

NotifyAndFlushBufferText ( StringBuilder textbuffer, bool isstdout ) : void

Invokes the OnStdoutTextRead (if isstdout==true)/ OnStderrTextRead events with the supplied streambuilder 'textbuffer', then clears textbuffer after event is invoked.

ReadStandardErrorThreadMethod ( ) : void

Method started in a background thread (stderrThread) to manage the reading and reporting of standard error text produced by the running process.

ReadStandardOutputThreadMethod ( ) : void

Method started in a background thread (stdoutThread) to manage the reading and reporting of standard output text produced by the running process.

ReadStream ( int firstCharRead, StreamReader streamReader, bool isstdout ) : void

Read characters from the supplied stream, and accumulate them in the 'streambuffer' variable until there are no more characters to read.

Time_Tick ( object sender, EventArgs e ) : void

메소드 상세

ProcessIoManager() 공개 메소드

Initializes a new instance of the ProcessIoManager class.
Does not automatically start listening for stdout/stderr. Call StartProcessOutputRead() to begin listening for process output.
public ProcessIoManager ( Process process ) : System
process System.Diagnostics.Process The process.
리턴 System

StartProcessOutputRead() 공개 메소드

Starts the background threads reading any output produced (standard output, standard error) that is produces by the running process.
public StartProcessOutputRead ( ) : void
리턴 void

StopMonitoringProcessOutput() 공개 메소드

Stops both the standard input and stardard error background reader threads (via the Abort() method)
public StopMonitoringProcessOutput ( ) : void
리턴 void

WriteStdin() 공개 메소드

Writes the supplied text string to the standard input (stdin) of the running process
In order to be able to write to the Process, the StartInfo.RedirectStandardInput must be set to true.
public WriteStdin ( string text ) : void
text string The text to write to running process input stream.
리턴 void