NET 11 introduces several new Process APIs that eliminate the classic deadlock risk when reading stdout/stderr from child processes. The new APIs include Process.ReadAllText()/ReadAllTextAsync() for safely capturing all output as strings, Process.ReadAllLines()/ReadAllLinesAsync() for consuming output line-by-line as it's produced (using IEnumerable/IAsyncEnumerable), Process.ReadAllBytes()/ReadAllBytesAsync() for raw byte output, and the convenience Process.RunAndCaptureText()/RunAndCaptureTextAsync() which handles start, capture, and wait in a single call. All new APIs handle parallel pipe draining internally (overlapped IO on Windows, poll-based multiplexing on Unix) to prevent deadlocks, and support timeout or cancellation token parameters.
8.1K Impressions1 Comment