Skip to content

StandardProcessWorkloadAdapter

Namespace: Hex1b

Assembly: Hex1b.dll

A workload adapter that wraps a standard .NET with redirected I/O.

csharp
public sealed class StandardProcessWorkloadAdapter : IHex1bTerminalWorkloadAdapter, IAsyncDisposable

Inheritance

ObjectStandardProcessWorkloadAdapter

Implements

Constructors

StandardProcessWorkloadAdapter(ProcessStartInfo)

Creates a new standard process workload adapter.

Parameters:

  • startInfo (ProcessStartInfo): The process start info. Note that , , and will be set to true automatically.
csharp
public StandardProcessWorkloadAdapter(ProcessStartInfo startInfo)

Properties

ExitCode

Gets the exit code, or -1 if not exited.

Returns: Int32

csharp
public int ExitCode { get; }

HasExited

Gets whether the process has exited.

Returns: Boolean

csharp
public bool HasExited { get; }

HasStarted

Gets whether the process has been started.

Returns: Boolean

csharp
public bool HasStarted { get; }

ProcessId

Gets the process ID, or -1 if not started.

Returns: Int32

csharp
public int ProcessId { get; }

Methods

DisposeAsync()

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

Returns: ValueTask

A task that represents the asynchronous dispose operation.

csharp
public ValueTask DisposeAsync()

Kill()

Kills the process.

csharp
public void Kill()

ReadOutputAsync(CancellationToken)

Read output FROM the workload (ANSI sequences to display). The terminal calls this to get data to parse and send to presentation. Returns empty when workload has no more output (should be called in a loop).

Parameters:

Returns: ValueTask<Byte>>

csharp
public ValueTask<ReadOnlyMemory<byte>> ReadOutputAsync(CancellationToken ct = default)

ResizeAsync(int, int, CancellationToken)

Notify workload of terminal resize.

Parameters:

Returns: ValueTask

csharp
public ValueTask ResizeAsync(int width, int height, CancellationToken ct = default)

StartAsync(CancellationToken)

Starts the process.

Parameters:

Returns: Task

csharp
public Task StartAsync(CancellationToken ct = default)

WaitForExitAsync(CancellationToken)

Waits for the process to exit.

Parameters:

Returns: Task<Int32>

The exit code of the process.

csharp
public Task<int> WaitForExitAsync(CancellationToken ct = default)

WriteInputAsync(ReadOnlyMemory<byte>, CancellationToken)

Write input TO the workload (raw bytes from keyboard/mouse). The terminal calls this when it receives input from the presentation layer.

Parameters:

Returns: ValueTask

csharp
public ValueTask WriteInputAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)

Events

Disconnected

Raised when workload has disconnected/exited.

Returns: Action

csharp
public event Action? Disconnected

Remarks

This adapter uses standard process redirection (stdin/stdout/stderr) rather than pseudo-terminal (PTY) emulation. This means:

No native library dependencies - works on all .NET platformsPrograms won't detect a TTY (isatty() returns false)No ANSI escape sequence processing by the child process's libcPrograms like vim, tmux, and screen won't work correctly

Use this for:

Simple command-line programs that output textBuild tools, compilers, and other non-interactive programsCross-platform scenarios where PTY isn't available

For full terminal emulation with PTY support, use instead.

Released under the MIT License.