title: Fill dataGridView thank's to backGroundWorker
body: <p>I have this code snippet:</p>
  
  <pre><code>private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
      {
          remplirDataGrid();
      }
  
  private void frmChercherActesLoad(object sender, EventArgs e)
          {
              backgroundWorker1.RunWorkerAsync();
  
          }
  
  
  
   private void remplirDataGrid()
          {
              dataGridView1.DataSource = ActeServices.getAllActes(0, 40);
              dataGridView1.Columns[0].Visible = false;
              dataGridView1.Columns[1].HeaderText = "Code acte";
              dataGridView1.Columns[2].HeaderText = "Désignation";
              dataGridView1.Columns[3].HeaderText = "Pris en charge";
              dataGridView1.Columns[4].HeaderText = "Id article";
              dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
          }
  </code></pre>
  
  <p>And here is the method <code>getAllActe</code>:</p>
  
  <pre><code>public static IEnumerable&lt;Acte&gt; getAllActes(int skipCount, int takeCount)
          {
              var myTableAdapter = new SmartDocDALServices.SmartDocDataSetTableAdapters.actesTableAdapter();
              myTableAdapter.Fill(myDataSet.actes);
              var myResult = from q in myDataSet.actes.AsEnumerable()
                              select new Acte
                              {
                                  code = q.code,
                                  designation = q.designation,
                                  priseEnCharge = q.prise_en_charge,
                                  idArticle = q.id_article,
                              };
  
              if (skipCount != -1)
                  myResult.Skip(skipCount);
              if (takeCount != -1)
                  myResult.Take(takeCount);
              IEnumerable&lt;Acte&gt; myResultRet = myResult.ToList();
              return myResultRet;
  </code></pre>
  
  <p>What I like to do is to fill my <code>datagridview</code> using the background worker once I run the application I got this error:</p>
  
  <blockquote>
    <p>Inter-thread operation not valid: Control 'dataGridView1 has been the subject of an access from a thread other than the one it was created.</p>
  </blockquote>
  
  <hr>
  
  <p>I try this </p>
  
  <pre><code> private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
      {
        IEnumerable&lt;Acte&gt; result = ActeServices.getAllActes(0, 40);
         backgroundWorker1.ReportProgress(0, result);
  
      }
  
      void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
      {
  
        dataGridView1.DataSource = (IEnumerable&lt;Acte&gt;)e.UserState;
        dataGridView1.Columns[0].Visible = false;
        dataGridView1.Columns[1].HeaderText = "Code acte";
       ***
  </code></pre>
  
  <p>but nothing gained in time?. I'd like that the datagrid update when the BGW loads data foreash data load it add it to the DGV</p>