Load View in a TabWorkspace's page without block others pages

Topics: CAB & Smart Client Software Factory
Mar 21, 2007 at 1:06 PM

I'm trying to load a grid in a view added to a tabworkspace, but the time to load the grid is very high. I get the grid's data from a web service in an asyncrhonous way(during the web service call I can change between tabworkspace's pages) but when I load the data in the grid, my application keeps blocked (I can't change between tabworkspace's pages). I try to load the data in the grid starting other thread but no work. Any ideas?¿

Thanks and sorry by my english,
Mar 21, 2007 at 1:48 PM
Are you adding items one by one or setting a datasource? Try suspending the layout of the grid while you add the items to it. To do this, do:
// ... add items here

Let me know if this was indeed your problem.
Julian Dominguez
Mar 21, 2007 at 2:38 PM
Thanks for the answer.
I'm adding items one by one, so it consume a lot of time.

I do this in the View's presenter:

Thread updateViewThread = new Thread(new ThreadStart(UpdateView));

private delegate void UpdateViewDelegate();

private void UpdateView()
if (View.Grid.InvokeRequired)
UpdateViewDelegate updateViewDelegate = new UpdateViewDelegate(UpdateView);
View.Grid.Invoke(updateViewDelegate, null);

But it doesn't work, when I load and format the grid the application is blocked.
Mar 21, 2007 at 3:20 PM
If you are adding lots of items, even suspending the layout could take a lot of time, and notice that this is always done in the UI thread. Maybe you could generate a datasource, passing the items one by one as you are doing now (perhaps a DataTable or a collection of displayable items), and after you have created this, call the UI thread to load them up in a single call, and format the grid (these 2 things still using suspend and resume layout to better improve performance and avoid flickering)

Let me know if this works better for you,
Julián Domínguez
Mar 21, 2007 at 6:15 PM
On those occasions where I have had to load large amounts of data (> 2000 rows) I always (if possible) use virtual loading.
1) Load all the data into a datasource or maybe you have the data available in some list form
2) Have the grid request the data from the source on demand. Most advanced grids supports this.

Mar 22, 2007 at 7:33 AM
I've data in a dataset but ComponentOne grid (flexgrid) hasn`t the behavior I need when I use the dataset so I've to add data row by row.

Thanks anyway.
Mar 22, 2007 at 3:18 PM
I believe we are moving a little off topic (for this forum), but I just looked at the product page for FlexGrid. They state that:

"Bound or unbound mode and custom data sources
Use the grid in bound mode, where it displays data from an ADO.NET data source, or in unbound mode, where the grid itself manages the data. You’re in charge: bind the grid to existing data structures, use calculated “virtual” fields, perform data validation, or load data on demand."

I haven't used flexGrid, but AFAIK, most grids will let you load on demand. One case where this gets a little tricky is when you have hierarchical data.