Actually, that is filling a DataSet/DataTable, not a DataGridView; to
do this without blocking, simply don't attach the set/table to the
DataGridView (as DataSource), and populate it on a non-UI thread, then
jump back when full to populate.
Something like (untested):
void fillButton_Click(object sender, EventArgs args) { // called on UI
thread
// may need to detach DataSource here (if present) or suspend
binding (RaiseListChangedEvents?)
myDataGridView.DataSource = null;
// spawn some work in the background
ThreadPool.QueueUserWorkItem(FillData);
}
void FillData(object state) { // called on background thread
this.xyzTableAdapter.Fill(this.myDataSet.MyMember) ;
// OK; have some data; attach the DataSource (need to jump to UI
thread):
this.Invoke((MethodInvoker) delegate {
myDataGridView.DataSource = myDataSet; // or table
});
}