private static void _queueWrite(ConsoleColor color, object src, string data) { #if DEBUG ConsoleWrite item = new ConsoleWrite(color, src, data); writeQueue.Enqueue(item); #endif }
private static void write() { ConsoleWrite qCurrent = null; do { if (writeQueue.Count > 0) { if (writeQueue.TryDequeue(out qCurrent)) { //Set restore color ConsoleColor originalColor = Console.ForegroundColor; //Write src name in the passed color Console.ForegroundColor = qCurrent.Color; Console.Write(qCurrent.Source); //Write the originating thread id in white Console.ForegroundColor = ConsoleColor.White; Console.Write("[{0}]", qCurrent.ThreadID); //Write the divider in yellow Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("::"); //Write the data in the passed color Console.ForegroundColor = qCurrent.Color; Console.Write(qCurrent.Data); //Is this an exception? if (qCurrent.Ex != null) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(qCurrent.Ex.Message); Console.ForegroundColor = originalColor; Console.Write(" : \r\n"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write(qCurrent.Ex.StackTrace); //Exceptions always write line Console.Write("\r\n"); } //Restore the color Console.ForegroundColor = originalColor; } } } while (processQueue); }
private static void _queueError(ConsoleColor color, object src, string data, Exception ex) { ConsoleWrite item = new ConsoleWrite(color, src, data, ex); writeQueue.Enqueue(item); }