static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread loggerThread = new Thread(() => Application.Run(loggerW = new LoggerWindow())); loggerThread.Start(); Application.Run(mainWindow = new MainWindow()); }
public static void AppendLog(LOG_LEVEL level, String message) { if (logfile == null) { return; } // Need to create some async queue if (!logfile.CanWrite) { return; } if (!Convert.ToBoolean(log_level & level)) { return; } // Add new line marker to end of each message message += Environment.NewLine; char[] mess = message.ToCharArray(); logfile.Write(Encoding.Default.GetBytes(mess), 0, Encoding.Default.GetByteCount(mess)); if (Program.loggerW == null) { return; } Program.loggerW.Invoke(new Action(delegate() { switch (level) { case LOG_LEVEL.LOG_LEVEL_ERROR: LoggerWindow.SetTextboxColor(System.Drawing.Color.Red); break; case LOG_LEVEL.LOG_LEVEL_INFO: LoggerWindow.SetTextboxColor(System.Drawing.Color.GreenYellow); break; case LOG_LEVEL.LOG_LEVEL_WARNING: LoggerWindow.SetTextboxColor(System.Drawing.Color.Yellow); break; default: LoggerWindow.SetTextboxColor(System.Drawing.Color.White); break; } LoggerWindow.PutInLog(message); })); }