Silverlight UI 线程冻结

发布于 2024-10-16 03:54:21 字数 192 浏览 8 评论 0原文

我有一个网格控件正在尝试显示大量数据,因此在 UI 线程上渲染需要很长时间。

我添加了一个加载栏,它根据屏幕是否繁忙(正在渲染)进行动画和显示。

然而,当网格尝试渲染时,加载栏只是冻结。我假设这是因为只有一个 UI 线程并且该线程很忙。

有谁知道如何使加载栏保持动画状态?

非常感谢,

马特

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甩你一脸翔 2024-10-23 03:54:21

您需要处理从 UI 渲染中获取的枚举或数据,执行处理部分以在单独的线程上为 UI 渲染做好准备。

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

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

猫烠⑼条掵仅有一顆心 2024-10-23 03:54:21

如果你坚持让网格一次渲染所有数据,这完全取决于网格的渲染代码是否可以“yield”,有点像旧的 Windows 窗体“DoEvents()”方法。听起来它的实现方式实际上并没有在渲染期间将处理返回给 UI 线程,因此您的进度条永远不会更新。

网格在渲染其内容时是否会调用您自己的代码?如果是这样,您可以使用这些实例来更新进度栏的状态。

您是否考虑过虚拟化网格的内容?如果您将需要渲染的 FrameworkElements 包装在 VirtualizingStackPanel 中,则基本上可以免费获得 UI 虚拟化。如果您想要更复杂一些,您还可以通过使用 PagedCollectionView 类包装数据集,然后编写 .有关更多详细信息,请参阅此处。另请参阅此处了解另一种(更简单?)的方法实施相同类型的虚拟化。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文