C# Class CodeArtEng.Diagnostics.ProcessExecutor

Execute Console based application without showing the console window.
Show file Open project: Code-Artist/CodeArtEng.Diagnostics

Private Properties

Property Type Description
DisposeProcessHandler void
KillProcessAndChildren void
process_ErrorDataReceived void
process_Exited void
process_OutputDataReceived void

Public Methods

Method Description
Abort ( ) : void

Stop the current process and all its child process.

Execute ( bool waitForExit = true ) : ProcessResult

Execute process and return result in the form of ProcessResult.

No exception is expected from this application. Execution error will be reflected in ExitCode.

ProcessExecutor ( string name = "Unnamed" ) : System

Constructor

RedirectOutputToFile ( string logFile ) : void

Redirect standard output and standrad error to file. By default, standard output and standard error are stored in ProcessResult which returned at the end of Execute()

Validate ( ) : void

Check if the specific tool exists.

Protected Methods

Method Description
Version ( string command ) : System.Version

Get tools version.

Private Methods

Method Description
DisposeProcessHandler ( ) : void
KillProcessAndChildren ( int pid ) : void
process_ErrorDataReceived ( object sender, DataReceivedEventArgs e ) : void
process_Exited ( object sender, EventArgs e ) : void
process_OutputDataReceived ( object sender, DataReceivedEventArgs e ) : void

Method Details

Abort() public method

Stop the current process and all its child process.
public Abort ( ) : void
return void

Execute() public method

Execute process and return result in the form of ProcessResult.
No exception is expected from this application. Execution error will be reflected in ExitCode.
public Execute ( bool waitForExit = true ) : ProcessResult
waitForExit bool Set to true to wait until process exit, else return once process started.
return ProcessResult

ProcessExecutor() public method

Constructor
public ProcessExecutor ( string name = "Unnamed" ) : System
name string Instance name
return System

RedirectOutputToFile() public method

Redirect standard output and standrad error to file. By default, standard output and standard error are stored in ProcessResult which returned at the end of Execute()
public RedirectOutputToFile ( string logFile ) : void
logFile string Target file to store output logs.
return void

Validate() public method

Check if the specific tool exists.
public Validate ( ) : void
return void

Version() protected method

Get tools version.
protected Version ( string command ) : System.Version
command string Command to retrieve version number, e.g. "/?", "--version"
return System.Version