I would suggest creating a delegate to invoke a method on just the data grid view.
One note: The columns at least need to be present (or created first in that invoke before the rows).
private void Load() {
Thread primarythrd = new Thread(primaryload);
primarythrd.IsBackground = true;
primarythrd.SetApartmentState(System.Threading.ApartmentState.STA);
primarythrd.Start();
}
delegate void AddRows(DataGridView view);
public void primaryload()
{
AddRows addRows = new AddRows(DoRowAdd);
this.Invoke(addRows, dataGridView1);
}
private void DoRowAdd(DataGridView view) {
if (view.InvokeRequired) {
AddRows rows = new AddRows(DoRowAdd);
this.Invoke(rows, new object[] { view });
}
else {
for (int i = 0; i < 100; i++) {
view.Rows.Add(item, malecount, femalecount, malecount + femalecount,
}
}
}