title: What's the best way to asynchronously load data into a Data Grid View?
body: <p>This code allows the form to load before the data is loaded but some of the components on the form such as buttons and the datagridview itself are "invisible" until the data is loaded.</p>
  
  <p>How do I fix this problem?</p>
  
  <pre><code>    private void Form1_Load(object sender, EventArgs e)
      {
          Thread t = new Thread(new ThreadStart(delegate()
          {
              this.Invoke(new MyDelegate(delegate()
              {               
                  ReadXml(path);
                  Bind();
             }));              
          }));
  
          t.Start();
       }
  
      private void Bind()
      {
          dataGridView1.DataSource = table;
      }
  </code></pre>
  
  <p>I also have this other code which works better, but requires that I use 2 new threads. This can't be the best way to do this, can it?</p>
  
  <pre><code>    private void Form1_Load(object sender, EventArgs e)
      {
          Thread t = new Thread(new ThreadStart(delegate()
            {
                this.Invoke(new InvokeDelegate(delegate()
                {
                    Thread t2 = new Thread(new ThreadStart(delegate()
                    {
                        ReadXml(path);
                    }));
                    t2.Start();
                    t2.Join();
                    Bind();
                }));
            }));
  
          t.Start();
      }
  </code></pre>