Skip to content

Instantly share code, notes, and snippets.

@timgaunt
Created September 4, 2012 11:01
Show Gist options
  • Save timgaunt/3620155 to your computer and use it in GitHub Desktop.
Save timgaunt/3620155 to your computer and use it in GitHub Desktop.
Queued Console.WriteLine
public static class QueuedConsole
{
private static StringBuilder _sb = new StringBuilder();
private static int _lineCount;
public void WriteLine(string message)
{
_sb.AppendLine(message);
++_lineCount;
if (_lineCount >= 10)
WriteAll();
}
public void WriteAll()
{
Console.WriteLine(_sb.ToString());
_lineCount = 0;
_sb.Clear();
}
}
QueuedConsole.WriteLine("This message will not be written directly, but with nine other entries to increase performance.");
//after your operations, end with write all to get the last lines.
QueuedConsole.WriteAll();
@timgaunt
Copy link
Author

timgaunt commented Sep 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment