Class Process
A class that represents a Windows Process. Similar to System.Diagnostics.Process, but not intended as a complete replacement.
Inheritance
Implements
Inherited Members
Namespace: Fs.Processes
Assembly: Fs.Processes.dll
Syntax
public sealed class Process : IDisposable
Constructors
| Improve this Doc View SourceProcess(CreateProcessInfo)
Creates a new process and assigns the process to the job object.
Declaration
public Process(CreateProcessInfo createProcessInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| CreateProcessInfo | createProcessInfo | The CreateProcessInfo that contains information this is used to start the process, including the file name and any command-line arguments. |
Process(CreateProcessInfo, ProcessOptions)
Creates a new process and assigns the process to the job object.
Declaration
public Process(CreateProcessInfo createProcessInfo, ProcessOptions processOptions)
Parameters
| Type | Name | Description |
|---|---|---|
| CreateProcessInfo | createProcessInfo | The CreateProcessInfo that contains information this is used to start the process, including the file name and any command-line arguments. |
| ProcessOptions | processOptions | A set of ProcessOptions that controls how the new process is created. |
Properties
| Improve this Doc View SourceExitCode
Gets the value associated with the process when it exited, or null if the process has not
exited.
Declaration
public int? ExitCode { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Int32> |
Exited
Gets a System.Threading.Tasks.Task that completes when the process exits. The System.Threading.Tasks.Task is cancelled if the Process is disposed before the process exits.
Declaration
public Task<int> Exited { get; }
Property Value
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Int32> |
Handle
Gets the Microsoft.Win32.SafeHandles.SafeProcessHandle associated with this instance.
Declaration
public SafeProcessHandle Handle { get; }
Property Value
| Type | Description |
|---|---|
| Microsoft.Win32.SafeHandles.SafeProcessHandle |
Id
Gets the unique identifier of the process.
Declaration
public int Id { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
StandardError
Gets a stream used to read from the redirected error output of the process.
Declaration
public StreamReader StandardError { get; }
Property Value
| Type | Description |
|---|---|
| System.IO.StreamReader |
StandardInput
Gets a stream used to write to the redirected input of the proces.
Declaration
public StreamWriter StandardInput { get; }
Property Value
| Type | Description |
|---|---|
| System.IO.StreamWriter |
StandardOutput
Gets a stream used to read from the redirected output of the process.
Declaration
public StreamReader StandardOutput { get; }
Property Value
| Type | Description |
|---|---|
| System.IO.StreamReader |
Methods
| Improve this Doc View SourceBeginReadingStandardErrorAsync(Boolean)
Begins asynchronous read operations on the redirected StandardError stream of the process.
Declaration
public Task BeginReadingStandardErrorAsync(bool readAsLines = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | readAsLines | When |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A System.Threading.Tasks.Task that completes when all data has been read. |
BeginReadingStandardOutputAsync(Boolean)
Begins asynchronous read operations on the redirected StandardOutput stream of the process.
Declaration
public Task BeginReadingStandardOutputAsync(bool readAsLines = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | readAsLines | When |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A System.Threading.Tasks.Task that completes when all data has been read. |
CancelReadingStandardError()
Cancels the asynchronous read operation on the redirected StandardError stream of the process.
Declaration
public void CancelReadingStandardError()
CancelReadingStandardOutput()
Cancels the asynchronous read operation on the redirected StandardOutput stream of the process.
Declaration
public void CancelReadingStandardOutput()
Dispose()
Releases all resources used by the instance.
Declaration
public void Dispose()
Kill(Int32)
Immediately stops the process.
Declaration
public void Kill(int exitCode = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | exitCode | The value to be used as the process's exit code. |
Resume()
Decrements the primary thread's suspend count. When the suspend count is decremented to zero, the execution of the thread is resumed.
Declaration
public bool Resume()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Events
| Improve this Doc View SourceErrorDataReceived
Occurs each time a process writes data to its redirected StandardError stream.
Declaration
public event EventHandler<ProcessDataReceivedEventArgs> ErrorDataReceived
Event Type
| Type | Description |
|---|---|
| System.EventHandler<ProcessDataReceivedEventArgs> |
OutputDataReceived
Occurs each time a process writes data to its redirected StandardOutput stream.
Declaration
public event EventHandler<ProcessDataReceivedEventArgs> OutputDataReceived
Event Type
| Type | Description |
|---|---|
| System.EventHandler<ProcessDataReceivedEventArgs> |