Sprog

Process.ReadAllLinesAsync(CancellationToken) Method

Definition

Asynchronously reads all standard output and standard error of the process as lines of text, interleaving them as they become available.

public System.Collections.Generic.IAsyncEnumerable<System.Diagnostics.ProcessOutputLine> ReadAllLinesAsync(System.Threading.CancellationToken cancellationToken = default);
member this.ReadAllLinesAsync : System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<System.Diagnostics.ProcessOutputLine>
Public Function ReadAllLinesAsync (Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of ProcessOutputLine)

Parameters

cancellationToken
CancellationToken

A token to cancel the asynchronous operation.

Returns

An async enumerable of ProcessOutputLine instances representing the lines read from standard output and standard error.

Exceptions

Standard output or standard error has not been redirected.

-or-

A redirected stream has already been used for synchronous or asynchronous reading.

The cancellationToken was canceled.

The process has been disposed.

Remarks

Lines from standard output and standard error are yielded as they become available. When the consumer stops enumerating early (for example, by breaking out of await foreach), any pending read operations are canceled.

Applies to