StandardProcessWorkloadAdapter
Namespace: Hex1b
Assembly: Hex1b.dll
A workload adapter that wraps a standard .NET with redirected I/O.
public sealed class StandardProcessWorkloadAdapter : IHex1bTerminalWorkloadAdapter, IAsyncDisposableInheritance
Object → StandardProcessWorkloadAdapter
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.
public StandardProcessWorkloadAdapter(ProcessStartInfo startInfo)Properties
ExitCode
Gets the exit code, or -1 if not exited.
Returns: Int32
public int ExitCode { get; }HasExited
Gets whether the process has exited.
Returns: Boolean
public bool HasExited { get; }HasStarted
Gets whether the process has been started.
Returns: Boolean
public bool HasStarted { get; }ProcessId
Gets the process ID, or -1 if not started.
Returns: Int32
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.
public ValueTask DisposeAsync()Kill()
Kills the process.
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:
ct(CancellationToken):
Returns: ValueTask<Byte>>
public ValueTask<ReadOnlyMemory<byte>> ReadOutputAsync(CancellationToken ct = default)ResizeAsync(int, int, CancellationToken)
Notify workload of terminal resize.
Parameters:
width(Int32):height(Int32):ct(CancellationToken):
Returns: ValueTask
public ValueTask ResizeAsync(int width, int height, CancellationToken ct = default)StartAsync(CancellationToken)
Starts the process.
Parameters:
ct(CancellationToken): Cancellation token.
Returns: Task
public Task StartAsync(CancellationToken ct = default)WaitForExitAsync(CancellationToken)
Waits for the process to exit.
Parameters:
ct(CancellationToken): Cancellation token.
Returns: Task<Int32>
The exit code of the process.
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:
data(ReadOnlyMemory<Byte>):ct(CancellationToken):
Returns: ValueTask
public ValueTask WriteInputAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)Events
Disconnected
Raised when workload has disconnected/exited.
Returns: Action
public event Action? DisconnectedRemarks
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.