title: Is there a faster way to print to a TextBox than AppendText?
body: <p>I have a background thread that is reading messages from a device and formatting them and passing them to the 'Consumer' node of a Producer/Consumer collection that then prints all of the messages to the string. The problem I am running into is that the logging lags a little bit behind the end of the process, so I am trying to find a faster way to print to the screen. Here is my consumer method:</p>
  
  <pre><code>private void DisplayMessages(BlockingCollection&lt;string[]&gt; messages)
  {
      try
      {
          foreach (var item in messages.GetConsumingEnumerable(_cancellationTokenSource.Token))
          {
              this.Invoke((MethodInvoker)delegate
              {
                  outputTextBox.AppendText(String.Join(Environment.NewLine, item) + Environment.NewLine);
              });
          }
      }
      catch (OperationCanceledException)
      {
          //TODO:
      }
  }
  </code></pre>
  
  <p>I have done some benchmark tests on my producer methods, and even logging to the console, and it does appear that writing to this TextBox is what is a little slower. During each process, I am logging ~61,000 lines that are about 60 characters long.</p>
  
  <p>I have researched that it is better to use .AppendText() than to say <code>textBox.Text += newText</code> as this resets the entire TextBox's text. I am looking for a solution that may include a faster way to print to a TB (or a UI element better suited for quick logging?) or if using <code>String.Join(Environment.NewLine, item)</code> is inefficient and could be sped up in any way.</p>