3

I have a grid control that is trying to display large amounts of data and so it takes a long time to render on the UI thread.

I have added a loading bar that animates and displays depending on if the screen is busy or not (is rendering).

However the loading bar is just freezing when the grid is trying to render. I am assuming this is because there is only one UI thread and that thread it busy.

Does anyone know a way in which I can keep the loading bar animated?

Many thanks,

Matt

Matthew Bill
  • 203
  • 3
  • 11

2 Answers2

0

You need to process the enumeration or data fetching from UI rendering, do the processing part for get the data ready for UI rendering on separate thread.

http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx

Bhupendra
  • 1,725
  • 22
  • 30
  • The data has already been got on a separate thread. This is not the bit that is taking the time, it is the actual physical rendering of that data. – Matthew Bill Feb 07 '11 at 15:41
0

If you insist on the grid rendering all the data at once, it all depends on whether the grid's rendering code can "yield" or not, kind of like the old Windows Forms "DoEvents()" method. It sounds like it's implemented in such a way that it doesn't, in fact, yield processing back to the UI thread during its rendering, and hence your progress bar never gets updated.

Does the grid ever call into your own code while it's rendering its content? If so, you could use those instances to update the state of the progress bar.

Have you looked into virtualizing the contents of the grid? You can get UI virtualization basically for free if you wrap the FrameworkElements that you need rendered in a VirtualizingStackPanel. If you want somewhat more complexity, you can also get data virtualization by wrapping your dataset with a PagedCollectionView class, and then writing . See here for more details. See also here for another (simpler?) way of implementing the same sort of virtualization.

Ken Smith
  • 20,305
  • 15
  • 100
  • 147
  • I said grid to try and simplify the problem in an abstract way. We are actually using one of Telerik's third party controls, so unfortunately we can't change the controls code. – Matthew Bill Feb 09 '11 at 10:45
  • Do you actually need to display all the data at once? Or would some sort of paging/virtualization/lazy retrieval scheme work? – Ken Smith Feb 09 '11 at 16:05