private void WriteToMessageHistory(string text, bool isSystemMessage = false) { if (TB_MessageHistory.Dispatcher.CheckAccess()) { if (isSystemMessage) { text = "[SYSTEM] " + text; } TB_MessageHistory.AppendText(text + Environment.NewLine); TB_MessageHistory.ScrollToEnd(); } else { TB_MessageHistory.Dispatcher.Invoke(new Action(() => WriteToMessageHistory(text, isSystemMessage))); } }
private void WriteToMessageHistory(string text, bool isSystemMessage = false) { if (TB_MessageHistory.Dispatcher.CheckAccess()) { if (isSystemMessage) { text = "[SYSTEM] " + text; } TB_MessageHistory.AppendText(text + Environment.NewLine); TB_MessageHistory.ScrollToEnd(); } else { try { TB_MessageHistory.Dispatcher.Invoke(new Action(() => { TB_MessageHistory.AppendText(text + Environment.NewLine); TB_MessageHistory.ScrollToEnd(); })); } catch (ThreadInterruptedException) { // do nothing } } }