title: Problem with BackgroundWorker
body: <p>I have written this code to read thousands of rows from Excel files and load them in a DataGridView.</p>
  
  <p>But the problem I am facing is, no matter which file I load, the DataGridView is showing the rows from the first file only and the _list is never cleared.</p>
  
  <pre><code>public class MyForm : Form
  {
      private List&lt;Student&gt; _list = null;
  
      private void LoadFile_Click(object sender, EventArgs e)
      {
          try
          {
              if (_list != null)
              {
                  _list.Clear();
              }
  
              openFileDialog1.ShowDialog();
  
              _connStr = MakeConnectionString.GetConnectionString(openFileDialog1.FileName);
  
              if (!string.IsNullOrEmpty(_connStr))
              {
                  backgroundWorker1.RunWorkerAsync();
              }
          }
          catch
          {
              MessageBox.Show("Application is busy with the first task!", "Busy...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
          }
      }
  
      private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
          if (backgroundWorker1.CancellationPending)
          {
              e.Cancel = true;
              return;
          }
  
          IDataReader read = StudentDA.GetReader(_connStr);
          List&lt;Student&gt; localList = null;
  
          if (_list != null)
          {
              _list.Clear();
          }
          _list = StudentMapper.GetStudents(read);
  
  
          localList = new List&lt;Student&gt;(_list);
  
          dataGridView1.Invoke(new MethodInvoker(delegate
          {
              dataGridView1.Rows.Clear();
          }));
  
          foreach (Student std in localList)
          {
              dataGridView1.Invoke(new MethodInvoker(delegate
              {
                  dataGridView1.Rows.Add(std.SerialNo, std.RollNo);
              }));
          }
      }
  }
  </code></pre>