title: Asynchronous UI updates in winforms
body: <p>I'd like to achieve similar effect in textbox in windows forms as you have in the output window in visual studio  - that means while it's printing some stuff, you can actually scroll down up and down freely. </p>
  
  <p>Unfortunatelly my attempts with async / await continue to be unsuccessfull (I'm blocking the UI ). </p>
  
  <p>So far I got this :</p>
  
  <pre><code>private async void button1_Click(object sender, EventArgs e)
      {
          try
          {
              richTextBox1.Text = "";
              if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
              {
                  await ProcessFile(openFileDialog1.FileNames.First());
              }
          }
          catch (Exception gg)
          {
              SupportingClass.SaveError(gg);
          }
      }
  //simplified
  private async Task ProcessFilecsv(string path)
  {
       IEnumerable&lt;T&gt; products = GetProducts&lt;T&gt;(path);
       foreach (var item in products)
       {
           string select = @"select something from datatable";
           List&lt;object[]&gt; result = await  Support.Overall.RetrieveSelectDataAsync(select);
  
           richTextBox1.AppendText(int.Parse(result[0][0].ToString()) &gt; 0 ? "Added" : "Not found"));
       }
  }
  </code></pre>
  
  <p>I also tried to use <code>Task.Factory.StartNew(()=&gt; dosth().ContinureWith(x =&gt; /* appending to richboxtext1 */ )</code> but also without success.</p>
  
  <p>What am I missing?</p>