Recently changed someone's code debugging times this mistake, debugging for a long time did not find any problems, Baidu did not find the corresponding solution.
Thread th = new Thread (new ThreadStart () =
{
Table. Rows.clear ();
Checksavedata ();
Binddatagrid (table);
}));
Th. IsBackground = true;
Th. Start ();
Later, after being explained, I thought about what the reason was. The general meaning of the error message is that the control of the form is manipulated inside the thread, and there was no code where the control of the form was called.
The problem is table. Rows.clear (), this line of code, because the form in the number of Gridcontrol binding data source is set to table, so when the online thread all rows of the table is Clear, triggered the
Gridcontrol data Change event, equal to the indirect operation of Gridcontrol, so the error is reported, as long as the line of code written to the thread on the line, the effect is the same.
C # Cross thread operation detected.