S
Stephan Steiner
Hi
I'm using several DataTables in my program which are updated periodically.
At the same I have those tables bound to DataGrids in my GUI. So far I've
been doing all the processing in the same program and the speed of the
processing prevented any issues when it comes to updating the GUI elements
(as DataTables are changed this triggers updates in the DataGrids), but as
soon as I add cpu time intensive processing options (i.e. receiving data
from the network rather than directly from the main thread), all hell breaks
loose because the GUI and processing threads interfere with each other. As
the link between DataTable and DataGrid is fully automatic, there's no
Control.Invoke that could be used to properly schedule GUI updates, so I'm
looking for a way to temporarily suspend updating the datagrid until the
required traffic from the net has been received and processed (and thus
resulted in updates to my DataTables). So far I have tried the following,
all without really succeeding:
- Clear the Databindings of the DataGrid, and then rebinding by setting the
DataGrid's DataSource to the respective DataTable. While clearing isn't a
problem, setting the DataSource anew triggers a System.ArgumentException
(Controls created on one thread cannot be parented to a control on a
different thread.).
- Having two DataTables for the same set of data, one for processing and one
for GUI display, and copy the content of the processing table to the display
table after processing is done. As DataTable.Clone only copies the structure
and not the content, I have to loop through the processing table and add
each row to the display table. This once again leads to undesired results as
my adding rows interferes with automatic GUI updates.
- Hide and Show the DataGrid which doesn't help either - it appears as if
the DataGrid is still updated even when it's not being shown.
That is so far all I've come up with. Any suggestions would be more than
welcome
Stephan
I'm using several DataTables in my program which are updated periodically.
At the same I have those tables bound to DataGrids in my GUI. So far I've
been doing all the processing in the same program and the speed of the
processing prevented any issues when it comes to updating the GUI elements
(as DataTables are changed this triggers updates in the DataGrids), but as
soon as I add cpu time intensive processing options (i.e. receiving data
from the network rather than directly from the main thread), all hell breaks
loose because the GUI and processing threads interfere with each other. As
the link between DataTable and DataGrid is fully automatic, there's no
Control.Invoke that could be used to properly schedule GUI updates, so I'm
looking for a way to temporarily suspend updating the datagrid until the
required traffic from the net has been received and processed (and thus
resulted in updates to my DataTables). So far I have tried the following,
all without really succeeding:
- Clear the Databindings of the DataGrid, and then rebinding by setting the
DataGrid's DataSource to the respective DataTable. While clearing isn't a
problem, setting the DataSource anew triggers a System.ArgumentException
(Controls created on one thread cannot be parented to a control on a
different thread.).
- Having two DataTables for the same set of data, one for processing and one
for GUI display, and copy the content of the processing table to the display
table after processing is done. As DataTable.Clone only copies the structure
and not the content, I have to loop through the processing table and add
each row to the display table. This once again leads to undesired results as
my adding rows interferes with automatic GUI updates.
- Hide and Show the DataGrid which doesn't help either - it appears as if
the DataGrid is still updated even when it's not being shown.
That is so far all I've come up with. Any suggestions would be more than
welcome
Stephan