예제 #1
0
        private static void _queueWrite(ConsoleColor color, object src, string data)
        {
#if DEBUG
            ConsoleWrite item = new ConsoleWrite(color, src, data);
            writeQueue.Enqueue(item);
#endif
        }
예제 #2
0
        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);
        }
예제 #3
0
        private static void _queueError(ConsoleColor color, object src, string data, Exception ex)
        {
            ConsoleWrite item = new ConsoleWrite(color, src, data, ex);

            writeQueue.Enqueue(item);
        }