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 2 7785
Oh, and one last thing, when you get the updates over the network, you
should not be updating the dataset on the thread that gets the updates.
Rather, you should pass the information to the UI thread through a call to
Invoke, and make the changes there. This is because the grid is bound to
the dataset and will handle the events fired from the data changing on that
thread (not the UI thread).
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Stephan Steiner" <st*****@shockfish.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... 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
Nicholas I don't understand what you mean when you say that "the link between DataTable and DataGrid is fully automatic, there's no Control.Invoke that could be used to properly schedule GUI updates".
Poor choice of words on my part. What I mean is that as soon as you set the
datasource of a datagrid, all changes you make to the datasource are
immediately carried over to the datagrid. So for instance if your datasource
is a datatable, editing a table cell will trigger an update of the datagrid.
I'm just guessing here, but I think that an update to the datasource
triggers a datasourcechanged event on the datagrid, and the datagrid is
redrawn. What I'd like is to temporarily suspend that mechanism, that is do
some processing on the tables (I mostly have them for internal processing,
the display is just a means to analyze how the application peforms on
various aspects and won't be available in the final release).
Oh, and one last thing, when you get the updates over the network, you should not be updating the dataset on the thread that gets the updates. Rather, you should pass the information to the UI thread through a call to Invoke, and make the changes there.
I figured so much, but due to the abovementioned, I'd rather have the
processing where it belongs, not have everything pass through control.invoke
first only to trigger the processing (since the whole datagrid display part
will eventually disappear). Isn't there a way to suspend events that are
fired when the data is changed, and once there are no more incoming updates,
enable the event again and fire one to trigger the update of the datagrid?
Stephan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Scott |
last post by:
Hi all.
A few days ago i ask this question and got a good quick response. I tried
out what they said and it worked. However I have now come to try the same
thing in another program and it...
|
by: mike |
last post by:
Hi there:
I've read an excellent "how to"-article by Microsoft (no. 306227) - partly
cited cited at the end of this email).
I have implemented the code related to the part "How to Add a...
|
by: Jeff |
last post by:
Hi -
I'm having trouble Databinding a SQLDataReader to a DataGrid control.
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in a directory of...
|
by: hope |
last post by:
Hi,
How can I format a string field using Data Formatting Expression property in
datagrid?
For example: format last name from BROWN to Brown.
Thanks
|
by: Daniel Doyle |
last post by:
Hello and apologies in advance for the amount of code in this post. I've
also sent this message to the Sharepoint group, but thought that ASP.NET
developers may also be able to help, even though...
|
by: Mark Waser |
last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a
datagrid.
In the page PreRender step, the selected index of the datagrid is
successfully set during databinding. Yet,...
|
by: G.Ashok |
last post by:
Hi,
Is there a way to suspend the background compilation of VB.NET in VS.NET
IDE?
I want to define a macro key to temporarily suspend and resume the
background compilation.
Regards,...
|
by: mcollier |
last post by:
I'm trying to develop a page template for the ASP.NET 1.1 project I'm
working on. I want to have something like Master Pages (from ASP.NET
2.0). I'm having a problem now with databinding on a...
|
by: tuka |
last post by:
Hi All,
Is there a way to temporarily suspend the use of imported libraries in
xslt ?
To be precise the issue I am trying to resolve is ,
I have a library imported as
<xsl:import...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |