Exemplo n.º 1
0
 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
         }
     }
 }