title: Clear the input buffer of a stream socket
body: <p>For a streaming application, when I switch between functions , I need to clear the input buffer. I have tried to do the following, it works but throws exceptions occasionally due to huge size of data pending in the pipeline.
  is there an alternative way to do this?</p>
  
  <pre><code>private async void ClearBuffer()
  {
      try
      {
          DataReader reader = soc.GetReaderStream();
          reader.InputStreamOptions = InputStreamOptions.Partial;
          uint count = reader.UnconsumedBufferLength;
  
          //if (count &gt; 0)
          {
               // TODO Buffer overflow exception
               await reader.LoadAsync(count);
               reader.ReadBuffer(count);
          }
      }
      catch (InvalidOperationException e)
      {
      }
  }
  </code></pre>
  
  <p>Thanks!</p>