Table of Contents

Class StreamConsumer

Namespace
NanoByte.Common.Streams
Assembly
NanoByte.Common.dll

Continuously reads lines from a StreamReader using a background thread while providing them to a foreground thread on demand.

public class StreamConsumer
Inheritance
StreamConsumer
Extension Methods

Remarks

Useful for processing StandardOutput and StandardError without risking deadlocks.

Constructors

StreamConsumer(StreamReader)

Starts reading from the stream in a background thread.

public StreamConsumer(StreamReader reader)

Parameters

reader StreamReader

The stream to read from.

Methods

ReadLine()

Returns the next pending line; null if there are no pending lines.

public string? ReadLine()

Returns

string

ToString()

Returns all buffered lines that have not been read yet.

public override string ToString()

Returns

string

WaitForEnd()

Waits for EndOfStream.

public void WaitForEnd()