title: C# - Cross Thread Error using Async and Await on TextBox
body: <p>I am new to Async and Await and have created a simple project in order to understand how it works.
  For this, I have a simple Windows Form application that has 2 elements:</p>
  
  <ul>
  <li>Get Completed Items button</li>
  <li>TextBox showing all Completed Items retrieved</li>
  </ul>
  
  <p>When I click the button, it should display all completed Items in the TextBox.
  This is the code I have written:</p>
  
  <pre><code>private async void btnGetCompletedItems_Click(object sender, EventArgs e)
  {
      QueueSystem queueSystem = QueueSystem.NewInstance(75);
  
      Stopwatch watch = new Stopwatch();
  
      watch.Start();
      await Task.Run(() =&gt; GetCompletedItems(queueSystem));
      watch.Stop();
  
      lblTime.Text = $"{watch.ElapsedMilliseconds.ToString()} ms";
  
  }
  
  private void GetCompletedItems(QueueSystem queueSystem)
  {
      foreach (var item in queueSystem.GetCompletedItems())
      {
          txtItems.Text += $"{txtItems.Text}{item.ItemKey}{Environment.NewLine}";
      }
  }
  </code></pre>
  
  <p>However, I am getting an error in </p>
  
  <blockquote>
    <p>txtItems.Text +=
    $"{txtItems.Text}{item.ItemKey}{Environment.NewLine}";</p>
  </blockquote>
  
  <p>The error says </p>
  
  <blockquote>
    <p>Additional information: Cross-thread operation not valid: Control
    'txtItems' accessed from a thread other than the thread it was created
    on.</p>
  </blockquote>
  
  <p>I checked in Debug and a new thread was created for GetCompletedItems(). When I read about Async and Await, I read that it doesn't necessarily create a new thread but it seems to have created a new one for some reason.</p>
  
  <p><strong>Is my implementation and understanding of Async and Await wrong?
  Is it possible to use Async and Await in a Windows Forms application?</strong></p>