Class StreamConsumer
Continuously reads lines from a StreamReader using a background thread while providing them to a foreground thread on demand.
public class StreamConsumer
- Inheritance
-
objectStreamConsumer
- 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
readerStreamReaderThe stream to read from.
Methods
ReadLine()
Returns the next pending line; null if there are no pending lines.
public string? ReadLine()
Returns
ToString()
Returns all buffered lines that have not been read yet.
public override string ToString()
Returns
WaitForEnd()
Waits for EndOfStream.
public void WaitForEnd()