Users noticed that records in the DataGridView started appearing on the screen with some delay.
So I analyzed logs and saw that there is a strong dependency between time that takes it to call DataTable.Rows.Add() and amount of records in data table. If in the beginning it takes less than 0.01 ms, it grows to 1 ms when there about 10000 records in the table and up to 5 ms when 50000. There are two threads: one adds records, the other deletes. DataTable is bounded to DataGridView meaning that it automatically updates gridview every time DataTable rows collection changes.
My understanding that on the amount on records like 100000 in the table there shouldn't be any delays like this. Should I consider implementing VirtualMode for DataGridView? I noticed that VirtualMode property set to true, but CellValueNeeded event not handled.
Code looks like this:
var row = table.NewRow();
//manipulations with row
table.Rows.Add(row);
row.AcceptChanges();
And delete:
var row = table.Rows.Find(id);
if (row != null) {
row.Delete();
row.AcceptChanges();
}