Table of Contents

Class ProcessWrapper

Namespace
GroupeIsa.Neos.Shared.IO
Assembly
GroupeIsa.Neos.Shared.dll

Represents the implementation of the IProcess interface.

public sealed class ProcessWrapper : IProcess, IDisposable
Inheritance
ProcessWrapper
Implements
Inherited Members

Constructors

ProcessWrapper(Process?)

Initializes a new instance of the ProcessWrapper class.

public ProcessWrapper(Process? process = null)

Parameters

process Process

The process to initialize the wrapper.

Properties

ExitCode

Gets the value that the associated process specified when it terminated.

public int ExitCode { get; }

Property Value

int

Id

Gets the unique identifier for the associated process.

public int Id { get; }

Property Value

int

IsRunning

Gets a value indicating whether the associated Process is running.

public bool IsRunning { get; }

Property Value

bool

StandardError

Gets a stream used to read the error of the application.

public 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.

public 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.

public StreamReader StandardOutput { get; }

Property Value

StreamReader

A StreamReader that can be used to read the standard output stream of the application.

StartInfo

Gets or sets the properties to pass to the Start() method of the Process.

public ProcessStartInfo StartInfo { get; set; }

Property Value

ProcessStartInfo

StartTime

Gets the time that the associated process was started.

public DateTime StartTime { get; }

Property Value

DateTime

Methods

BeginErrorReadLine()

Begins asynchronous read operations on the redirected StandardError property of this Process component.

public void BeginErrorReadLine()

BeginOutputReadLine()

Begins asynchronous read operations on the redirected StandardOutput property of this Process component.

public void BeginOutputReadLine()

CloseMainWindow()

Closes a process that has a user interface by sending a close message to its main window.

public 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).

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Kill(bool)

Immediately stops the associated process, and optionally its child/descendent processes.

public void Kill(bool entireProcessTree)

Parameters

entireProcessTree bool

true to kill the associated process and its descendants; false to kill only the associated process.

Start()

Starts the process resource that is specified by the StartInfo property of this Process component.

public 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.

public void WaitForExit()

WaitForExitAsync(CancellationToken)

Instructs the process component to wait for the associated process to exit, or for the cancellationToken to be cancelled.

public Task WaitForExitAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

An 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.

public event EventHandler<DataReceivedWrapperEventArgs>? ErrorDataReceived

Event Type

EventHandler<DataReceivedWrapperEventArgs>

Exited

Occurs when a Process exits.

public event EventHandler? Exited

Event Type

EventHandler

OutputDataReceived

Occurs each time an application writes a line to its redirected StandardOutput stream.

public event EventHandler<DataReceivedWrapperEventArgs>? OutputDataReceived

Event Type

EventHandler<DataReceivedWrapperEventArgs>