开发者

Silverlight UI Thread Freezing

开发者 https://www.devze.com 2023-02-08 20:16 出处:网络
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 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 becaus开发者_JAVA技巧e 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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号