Created
September 4, 2012 11:01
-
-
Save timgaunt/3620155 to your computer and use it in GitHub Desktop.
Queued Console.WriteLine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found on: http://stackoverflow.com/a/5272322