title: c# Fill textbox while listbox is being filled
body: <p>This is my code:</p>
  
  <pre><code>private void _1_Load(object sender, EventArgs e)
  {
      FillA();
      FillB();
      // Tried these lines too but they show listbox values but not textbox value
      //    var t2 = Task.Run(() =&gt; FillA());
      //    FillB();    
  }
  
  private void FillA()
  {
      this.Invoke(new MethodInvoker(delegate()
      {
          for (int i = 1; i &gt; 0; i++)
          {
              listBox1.Items.Add(i.ToString());
              listBox1.Update();
              Thread.Sleep(25);
          }
      }));
  }
  
  private void FillB()
  {
      Thread.Sleep(3000); //1 seconds delay
      textBox1.Text = "Hello World!";
  }
  </code></pre>
  
  <p>When the page loads the <code>listbox</code> should starts showing the number 1, 2, 3... and then after few seconds of delay the textbox should show the <code>Hello World!</code> value but the listbox should keep growing. How do I ensure that first the listbox should start filling and then the textbox should fill. I don't want to wait for the filling of the listbox and then textbox to be filled. </p>
  
  <p>Any advice would be appreciated.</p>
  
  <p><strong>Edit:</strong> 
  This is just a sample code. In actual production there would be two processes and the second process will start once the first process is started fetching data and storing in listbox.</p>
  
  <p>The first process should keep on going. I can't stop it in middle as it would create inconsistency in the data. </p>