NanoByte.Common  2.6.1
NanoByte.Common.Streams.StreamConsumer Class Reference

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

Public Member Functions

 StreamConsumer (StreamReader reader)
 Starts reading from the stream in a background thread. More...
 
string? ReadLine ()
 Returns the next pending line; null if there are no pending lines. More...
 
void WaitForEnd ()
 Waits for StreamReader.EndOfStream. More...
 
override string ToString ()
 Returns all buffered lines that have not been read yet. More...
 

Detailed Description

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

Useful for processing Process.StandardOutput and Process.StandardError without risking deadlocks.

Constructor & Destructor Documentation

◆ StreamConsumer()

NanoByte.Common.Streams.StreamConsumer.StreamConsumer ( StreamReader  reader)
inline

Starts reading from the stream in a background thread.

Parameters
readerThe stream to read from.

Member Function Documentation

◆ ReadLine()

string? NanoByte.Common.Streams.StreamConsumer.ReadLine ( )
inline

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

◆ ToString()

override string NanoByte.Common.Streams.StreamConsumer.ToString ( )
inline

Returns all buffered lines that have not been read yet.

◆ WaitForEnd()

void NanoByte.Common.Streams.StreamConsumer.WaitForEnd ( )

Waits for StreamReader.EndOfStream.


The documentation for this class was generated from the following file: