Class StreamConsumer
Continuously reads lines from a System.IO.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 System.Diagnostics.Process.StandardOutput and System.Diagnostics.Process.StandardError without risking deadlocks.
Constructors
StreamConsumer(StreamReader)
Starts reading from the stream in a background thread.
public StreamConsumer(StreamReader reader)
Parameters
reader
StreamReaderThe 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 System.IO.StreamReader.EndOfStream.
public void WaitForEnd()