C# Class ANHAdmin.ProcessCaller

This class can launch a process (like a bat file, perl script, etc) and return all of the StdOut and StdErr to GUI app for display in textboxes, etc.
This class (c) 2003 Michael Mayer Use it as you like (public domain licensing). Please post any bugs / fixes to the page where you downloaded this code.
Inheritance: AsyncOperation
Show file Open project: swganhtools/anhserverconfigurationtool Class Usage Examples

Public Properties

Property Type Description
SleepTime int
WorkingDirectory string
m_EDone bool
m_PDone bool
m_SDone bool

Public Methods

Method Description
AddOutput ( string line ) : void
ProcessCaller ( ISynchronizeInvoke isi ) : System

Initialises a ProcessCaller with an association to the supplied ISynchronizeInvoke. All events raised from this object will be delivered via this target. (This might be a Control object, so events would be delivered to that Control's UI thread.)

Protected Methods

Method Description
DoWork ( ) : void

/// Initialises a ProcessCaller without an association to an /// ISynchronizeInvoke. All events raised from this object /// will be delievered via the worker thread. ///

Launch a process, but do not return until the process has exited. That way we can kill the process if a cancel is requested.

ReadStdErr ( ) : void

Handles reading of stdErr

ReadStdOut ( ) : void

Handles reading of stdout and firing an event for every line read

StartProcess ( ) : void

This method is generally called by DoWork() which is called by the base classs Start()

Method Details

AddOutput() public method

public AddOutput ( string line ) : void
line string
return void

DoWork() protected method

/// Initialises a ProcessCaller without an association to an /// ISynchronizeInvoke. All events raised from this object /// will be delievered via the worker thread. /// Launch a process, but do not return until the process has exited. That way we can kill the process if a cancel is requested.
protected DoWork ( ) : void
return void

ProcessCaller() public method

Initialises a ProcessCaller with an association to the supplied ISynchronizeInvoke. All events raised from this object will be delivered via this target. (This might be a Control object, so events would be delivered to that Control's UI thread.)
public ProcessCaller ( ISynchronizeInvoke isi ) : System
isi ISynchronizeInvoke An object implementing the /// ISynchronizeInvoke interface. All events will be delivered /// through this target, ensuring that they are delivered to the /// correct thread.
return System

ReadStdErr() protected method

Handles reading of stdErr
protected ReadStdErr ( ) : void
return void

ReadStdOut() protected method

Handles reading of stdout and firing an event for every line read
protected ReadStdOut ( ) : void
return void

StartProcess() protected method

This method is generally called by DoWork() which is called by the base classs Start()
protected StartProcess ( ) : void
return void

Property Details

SleepTime public property

Amount of time to sleep on threads while waiting for the process to finish.
public int SleepTime
return int

WorkingDirectory public property

The WorkingDirectory (should be made into a property)
public string WorkingDirectory
return string

m_EDone public property

public bool m_EDone
return bool

m_PDone public property

public bool m_PDone
return bool

m_SDone public property

public bool m_SDone
return bool