Show / Hide Table of Contents

Interface IAsyncProcessRunner

Interface for running external processes asynchronously in the background. Supports monitoring state while running and provides process control.

Inherited Members
IDisposable.Dispose()
Namespace: Benday.Common
Assembly: Benday.Common.dll
Syntax
public interface IAsyncProcessRunner : IDisposable

Properties

| Edit this page View Source

ErrorText

Get the current error text. Can be called while process is running.

Declaration
string ErrorText { get; }
Property Value
Type Description
string
| Edit this page View Source

ExitCode

The exit code from the process. Returns -1 if not yet completed.

Declaration
int ExitCode { get; }
Property Value
Type Description
int
| Edit this page View Source

HasCompleted

Indicates if the process has completed.

Declaration
bool HasCompleted { get; }
Property Value
Type Description
bool
| Edit this page View Source

HasStarted

Indicates if the process has been started.

Declaration
bool HasStarted { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsError

Indicates if the process completed with an error.

Declaration
bool IsError { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsRunning

Indicates if the process is currently running.

Declaration
bool IsRunning { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsSuccess

Indicates if the process completed successfully.

Declaration
bool IsSuccess { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsTimeout

Indicates if the process timed out.

Declaration
bool IsTimeout { get; }
Property Value
Type Description
bool
| Edit this page View Source

OutputText

Get the current output text. Can be called while process is running.

Declaration
string OutputText { get; }
Property Value
Type Description
string
| Edit this page View Source

ProcessId

The process ID. Returns null if process has not started.

Declaration
int? ProcessId { get; }
Property Value
Type Description
int?
| Edit this page View Source

RunTimeout

The timeout in milliseconds for the overall process run duration. If exceeded, the process is terminated and IsTimeout becomes true. Default is 0 (no timeout - runs indefinitely).

Declaration
int RunTimeout { get; set; }
Property Value
Type Description
int
| Edit this page View Source

StartInfo

The ProcessStartInfo object used to configure the process.

Declaration
ProcessStartInfo StartInfo { get; }
Property Value
Type Description
ProcessStartInfo
| Edit this page View Source

StartupTimeout

The timeout in milliseconds for the process startup. The process must start within this time or a TimeoutException is thrown. Default is 5000ms (5 seconds).

Declaration
int StartupTimeout { get; set; }
Property Value
Type Description
int
| Edit this page View Source

UnderlyingProcess

Direct access to the underlying Process instance. Returns null if process has not started. Use with caution - prefer using the interface methods.

Declaration
Process? UnderlyingProcess { get; }
Property Value
Type Description
Process

Methods

| Edit this page View Source

Kill(bool)

Kill/stop the running process.

Declaration
void Kill(bool entireProcessTree = false)
Parameters
Type Name Description
bool entireProcessTree

If true, kills the entire process tree.

| Edit this page View Source

StartAsync(CancellationToken)

Start the process in the background (non-blocking).

Declaration
Task StartAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token.

Returns
Type Description
Task

Task that completes when the process has started.

Exceptions
Type Condition
InvalidOperationException

Thrown if StartAsync() is called more than once.

TimeoutException

Thrown if the process does not start within StartupTimeout.

| Edit this page View Source

WaitForExitAsync(CancellationToken)

Wait for the process to complete.

Declaration
Task WaitForExitAsync(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token.

Returns
Type Description
Task

Task that completes when the process has finished.

Extension Methods

ObjectAssertExtensions.ShouldBeNull<T>(T?, string)
ObjectAssertExtensions.ShouldBeSameAs<T>(T, T, string)
ObjectAssertExtensions.ShouldEqual<T>(T, T, string)
ObjectAssertExtensions.ShouldNotBeNull<T>(T?, string)
ObjectAssertExtensions.ShouldNotBeSameAs<T>(T, T, string)
ObjectAssertExtensions.ShouldNotEqual<T>(T, T, string)
ObjectAssertExtensions.ShouldBeOfType<T>(object?, string)
ObjectAssertExtensions.ShouldNotBeOfType<T>(object?, string)
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com