title: Delay function in C#
body: <p>I need to understand how can I create delays between a set of commands. My background is with C (DOS) and now reviving the concepts using C# in Visual Studio 2015. This is the code I am struggling with:</p>
  
  <pre><code>using System.Threading;
  
  private void button1_Click(object sender, EventArgs e)      // Button
  {
      int i;
      for (i = 0; i &lt; 10; i++)
      {
          textBox1.BackColor = Color.Red;
          Thread.Sleep(100);
          textBox1.BackColor = Color.Yellow;
          Thread.Sleep(100);
      }
  }
  </code></pre>
  
  <p>I was expecting the background color of the textbox will change alternatively 10 times but I could see only yellow color after the loop finishes. If I increase delay I do notice that program takes time to finish. I went through some related articles but couldn't get the point. Any help will be appreciated. Thanks</p>