title: How to load a windows form in new thread?
body: <p>c# .net Winforms,IDE: VS 2010</p>
  
  <p>I having two windows from F1, F2.  </p>
  
  <p>F1 is the caller, and F2 is the form which I want to load in thread because it is having lots of rich controls on it.</p>
  
  <p>I am able to load the f2 in child thread but it just get visible and goes, because its on child thread.(See Case 1 Code)</p>
  
  <p>Case 1 Code  </p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          StartProgress();
          Thread th = new Thread(new ThreadStart(LoadForm));
          th.Start();
  
      }
  
      private void StartProgress()
      {
          progressBar1.Maximum = 100;
          progressBar1.Step = 1;
          for (int i = 0; i &lt;= 100; i++)
          {
              label1.Text = i + "%";
              progressBar1.PerformStep();
              Thread.Sleep(10);
              label1.Refresh();
          }
      }
  
      private void LoadForm()
      {
          Form2 f2 = new Form2();
          f2.Show();
      }
  }  
  </code></pre>
  
  <p>Then I did reverse that is I loaded progress bar in child thread and loaded f2 on main thread.(See Case 2 Code)  </p>
  
  <p>//Code Case2:<br>
  case 2 when progress bar is on child thread.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      LoadForm();
      Thread th = new Thread(new ThreadStart(StartProgress));
      th.Start();
      LoadForm();
  }
  
  private void StartProgress()
  {
      progressBar1.Maximum = 100;
      progressBar1.Step = 1;
      for (int i = 0; i &lt;= 100; i++)
      {
          label1.Text = i + "%";
          progressBar1.PerformStep();
          Thread.Sleep(10);
          label1.Refresh();
      }
  }
  
  private void LoadForm()
  {
      Form2 f2 = new Form2();
      f2.Show();
  }
  </code></pre>
  
  <p>but case 2 having 2 problems.</p>
  
  <p>Problem 1: It loads the f2 as usual with flicking.
  Problem 2: Cross Thread Opration progressbar1</p>
  
  <p>//Pls suggest how to load the f2 in background and show it after the progress bar is loaded.</p>