title: Determine if PipeStream has data
body: <p>I am using named pipes to communicate some messages between applications.</p>
  
  <p>My pipe client reads a message sent from the server using <code>PipeStream.ReadByte()</code>. This blocks the thread it is running in.</p>
  
  <p>This behavior is generally fine, however, I cannot figure out a good way to dispose of that thread while it is being blocked. When the client exits, that thread stays alive until the stream gets some data and it is allowed to check the looping variable again. In the case where the server goes silent, the thread just lives.</p>
  
  <p><code>Thread.Abort()</code> has no effect.</p>
  
  <p>Is there a way to check the stream from data before moving to the <code>ReadByte()</code> method? <code>PipeStream.Length</code> throws <code>UnsupportedException</code>.</p>