title: Why isn't this thread reading all data from the pipe consistently?
body: <p>Anything wrong with this in general?</p>
  
  <pre><code>CallingFunction()
  {
     CreatePipe()
     CreateMutex()
     CreateThread( ThreadFunction )
  
     while(there is data left to send)
     {
        WriteFile(send data in 256 byte chunks)
     }
  
     WaitForSingleobject() //don't return until ReadThread is done
  
     return 0;
   }
  
  ThreadFunction()
  {
     WaitForSinglObject()
  
     while(bytesRead != totalBytestoReadFileSize)
     {
        ReadfromPipe(in chunks)
        update bytesRead++
     }
  
     ReleaseMutex()
  
     return 0;
   }
  </code></pre>
  
  <p>Before the calling function ends -</p>
  
  <p>FileSize: 232016<br>
  BytesWrittenToPipe: 232016<br>
  BytesReadFromPipe: 231946 or 232012 or 231840  -> Why not consistent?</p>