.NET 11 adds Process.RunAndCaptureText to avoid process deadlocks
.NET 11 introduces one-shot Process helpers: RunAndCaptureText starts a process, reads stdout and stderr concurrently, waits for exit and returns both strings, the exit code and the PID. This fixes the classic deadlock from reading redirected streams sequentially. The APIs ship in RC2 under a go-live license.
- RunAndCaptureText returns StandardOutput, StandardError, ExitStatus and ProcessId
- The sync version drains both pipes on one thread; the async twin uses async I/O
- A built-in timeout throws TimeoutException and kills the child process
- The APIs are unsupported on iOS and tvOS and fail with CS0117 on .NET 10
Read next
Software