C # Assigning DataRow ["haswhatnots"] = hasWhatnots is terribly slow

C # Assigning DataRow ["haswhatnots"] = hasWhatnots is terribly slow. hasWhatnots is a boolean.

I have profiled this line and with 560,000 hits the execution time is 82 seconds. Of course, the profiler has some impact on performance, but still the performance of this is very slow!

Any hints of this problem. A DataRow is part of a DataTable that is bound to a BindingSource bound to a DataGridView.Datasource.

+1
source share
3 answers

(: , ) , - ; , null . BindingSource SuspendBinding(), ResumeBinding() ResetBindings() .


- , DataColumn :

// early code, once only...
DataColumn col = table.Columns["haswhatnots"];

// "real" code, perhaps in a loop
row[col] = hasWhatnots;

, ( DataColumn ).

- class DataTable;-p

+2

bindingSource1.RaiseListChangedEvents = false;

// stuff the grid

bindingSource1.RaiseListChangedEvents = true;

, .

0

, -

DataRow row

row.BeginEdit();
row["haswhatnots"] = hasWhatnots;
row.EndEdit();

( 60 , 10 + ) , , .

0

Source: https://habr.com/ru/post/1755974/


All Articles