title: c# winform Invoke throws NullReferenceException
body: <p>i'm working on an winform(mdi) pro. And I need to update a dataGridView control when i get new data from another thread. and when new data comes and i'm dragging the dataGridview scroll, it throw a nullreference exception in dataGridView.Invoke.  i have searched for few days and drove google crazy，but didn't help. 
  the code like this:</p>
  
  <pre><code>  
      public void ReceiveNewData(object sender, UpateEventArgs ex)
      {
          if (this.dataGridView.InvokeRequired)
          {
              dataGridView.Invoke(new UpateEventHandler(ReceiveNewData), new object[] { this, ex });
          }
          else
              this.BindNewData();
      }
  
      private void BindNewData()
       {
  
          if (dataGridView!= null && (QuoteMember.listOneClickQuoteItem != null || QuoteMember.listMarketingQuoteItem != null))
          {
              DataTable dataSource = PublicFunction.ToDataTable(QuoteMember.listOneClickQuoteItem);
              if (dataSource != null)
                      dataSource.Merge(PublicFunction.ToDataTable(QuoteMember.listMarketingQuoteItem), true);
                  else
                      dataSource = PublicFunction.ToDataTable(QuoteMember.listMarketingQuoteItem);
              dataGridView.DataSource = dataSource;
          }
      }
  
  public PublicFunction
  {
          public static DataTable ToDataTable(List dataSource)
          {
              if(dataSource != null)
                  return ToDataTable((dataSource.ToArray()), 1);
              return null;
          }
  
          public static DataTable ToDataTable(List dataSource) 
          {
              if (dataSource != null)
                  return ToDataTable((dataSource.ToArray()), 2); 
              return null; 
          }
          private static DataTable ToDataTable(QuoteItemBase[] m, int type)
          {
              DataTable dsTemp = null;
  
              if (type == 1)
              {
                  dsTemp = new DataTable("OneClickQuote");
              }
              else if (type == 2)
              {
                  dsTemp = new DataTable("MarketingQuote");
              }
              else
                  dsTemp  = new DataTable("temptable");
  
              dsTemp.Columns.Add("Date");
              dsTemp.Columns.Add("Time");
              dsTemp.Columns.Add("NO");
              dsTemp.Columns.Add("Name");
  
  
              if (m == null)
                  return dsTemp;
  
              foreach (var item in m)
              {
                  DataRow drTemp = dsTemp.NewRow();
                  drTemp["Date"] = item.date;
                  drTemp["Time"]  = item.time;
                  drTemp["NO"] = item.no;
                  drTemp["Name"] = item.name;
                  dsTemp.Rows.Add(drTemp);
  
              }
  
              return dsTemp;
        }
  }
  
  
  
  
  
  
  </code></pre>
  
  <p>PS:
    if new data comes and i'm not dragging scroll bar, it works fine.</p>
  
  <p>any ideas? 
  thank you !</p>