Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirectStandardOutput is buffering lines instead of being instantaneous?
    primarykey
    data
    text
    <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 = @"C:\tail.exe"; private const string logFile = @"C:\test.log"; private static void ReadStdOut() { var psi = new ProcessStartInfo { FileName = tailExecutable, Arguments = String.Format("-f \"{0}\"", logFile), UseShellExecute = false, RedirectStandardOutput = true }; // Running same exe -args through cmd.exe // works perfectly, but not programmatically. Console.WriteLine("{0} {1}", 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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload