title: RedirectStandardOutput is buffering lines instead of being instantaneous?
body: <p>Ok, I am trying to use Tail to monitor a log file, but I cannot get the same behavior programatically as when I manually run it through cmd prompt using the same parameters.</p>
  <p>When run through cmd prompt it displays the new lines <strong>instantly</strong>. Programatically though, I have to wait for about <strong>75+ new lines</strong> in log file before the 'buffer' unleashes all the lines.</p>
  <p>Here's the code I have now.</p>
  <pre><code>private const string tailExecutable = @&quot;C:\tail.exe&quot;;
  private const string logFile = @&quot;C:\test.log&quot;;
  
  private static void ReadStdOut()
  {
      var psi = new ProcessStartInfo
      {
          FileName = tailExecutable,
          Arguments = String.Format(&quot;-f \&quot;{0}\&quot;&quot;, logFile),
          UseShellExecute = false,
          RedirectStandardOutput = true
      };
  
      // Running same exe -args through cmd.exe 
      // works perfectly, but not programmatically.
      Console.WriteLine(&quot;{0} {1}&quot;, psi.FileName, psi.Arguments);
  
      var tail = new Process();
      tail.StartInfo = psi;
      tail.OutputDataReceived += tail_OutputDataReceived;
      tail.Start();
      tail.BeginOutputReadLine();
  }
  
  static void tail_OutputDataReceived(object sender, DataReceivedEventArgs e)
  {
      Console.WriteLine(e.Data);
  }
  </code></pre>
  <p>I have used the OutputDataReceived event before but never had these buffering/spamming problems.</p>
  <p>I am so confused with about right now.</p>
  <h2>* <strong>Edit</strong> *</h2>
  <p>I found <a href="http://www.codeproject.com/KB/cs/wintail.aspx" rel="nofollow noreferrer">this wintail project on CodeProject</a> and am going to be switching to that because the buffer makes this solution way too slow.</p>
  <p>Thanks for the answers.</p>