private void ISLogger_MessageOut(object sender, string text) { if (ConsoleTextBox.InvokeRequired) { ConsoleTextBox.Invoke(new Action(() => ISLogger_MessageOut(null, text))); } else { ConsoleTextBox.AppendText(text); } }
public void WriteLine(string text) { if (ConsoleTextBox.InvokeRequired) { var del = new SafeCallTextDelegate(WriteLine); ConsoleTextBox.Invoke(del, text); } else { this.ConsoleTextBox.AppendText("[" + GetTimestamp() + "] " + text + Environment.NewLine); Console.WriteLine(text); } }
private void AppendToLog(string text) { try { var textToAppend = DateTime.Now + " | " + text + "\n"; try { ConsoleTextBox.AppendText(textToAppend); } catch (InvalidOperationException ex) { ConsoleTextBox.Invoke(new Action(() => ConsoleTextBox.AppendText(textToAppend))); } } catch (Exception ex) { Log.Error(ex.Message, ex); throw; } }