Interface IProcess
Enables you to start and stop local system processes.
public interface IProcess : IDisposable
- Inherited Members
Properties
ExitCode
Gets the value that the associated process specified when it terminated.
int ExitCode { get; }
Property Value
Id
Gets the unique identifier for the associated process.
int Id { get; }
Property Value
IsRunning
Gets a value indicating whether the associated Process is running.
bool IsRunning { get; }
Property Value
StandardError
Gets a stream used to read the error of the application.
StreamReader StandardError { get; }
Property Value
- StreamReader
A StreamReader that can be used to read the standard error stream of the application.
StandardInput
Gets a stream used to write the input of the application.
StreamWriter StandardInput { get; }
Property Value
- StreamWriter
A StreamWriter that can be used to write the standard input stream of the application.
StandardOutput
Gets a stream used to read the output of the application.
StreamReader StandardOutput { get; }
Property Value
- StreamReader
A StreamReader that can be used to read the standard output stream of the application.
StartInfo
ProcessStartInfo StartInfo { get; set; }
Property Value
StartTime
Gets the time that the associated process was started.
DateTime StartTime { get; }
Property Value
Methods
BeginErrorReadLine()
Begins asynchronous read operations on the redirected StandardError property of this Process component.
void BeginErrorReadLine()
BeginOutputReadLine()
Begins asynchronous read operations on the redirected StandardOutput property of this Process component.
void BeginOutputReadLine()
CloseMainWindow()
Closes a process that has a user interface by sending a close message to its main window.
bool CloseMainWindow()
Returns
- bool
true
if the close message was successfully sent;false
if the associated process does not have a main window or if the main window is disabled (for example if a modal dialog is being shown).
Kill(bool)
Immediately stops the associated process, and optionally its child/descendent processes.
void Kill(bool entireProcessTree)
Parameters
entireProcessTree
booltrue
to kill the associated process and its descendants;false
to kill only the associated process.
Start()
bool Start()
Returns
- bool
true
if a process resource is started; otherwise,false
.
WaitForExit()
Instructs the process component to wait for the associated process to exit.
void WaitForExit()
WaitForExitAsync(CancellationToken)
Instructs the process component to wait for the associated process to exit, or for the cancellationToken to be cancelled.
Task WaitForExitAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation.
Returns
- Task
A task that will complete when the process has exited, cancellation has been requested, or an error occurs.
Events
ErrorDataReceived
Occurs when an application writes to its redirected StandardError stream.
event EventHandler<DataReceivedWrapperEventArgs>? ErrorDataReceived
Event Type
Exited
Occurs when a Process exits.
event EventHandler? Exited
Event Type
OutputDataReceived
Occurs each time an application writes a line to its redirected StandardOutput stream.
event EventHandler<DataReceivedWrapperEventArgs>? OutputDataReceived