首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WPF密集型UI处理导致ContextSwitchDeadlock

WPF密集型UI处理导致ContextSwitchDeadlock
EN

Stack Overflow用户
提问于 2011-04-06 13:59:27
回答 1查看 850关注 0票数 0

我有一个WPF图表应用程序。基本上,用户从文件中输入数据,应用程序将数据绘制成图表。当图表中的点数变得非常大时,我会得到一个ContextSwitchDeadlock错误

The CLR has been unable to transition from COM context 0x23cda8 to COM context 0x23cf18 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

现在,我意识到这是因为UI线程不应该忙碌那么长时间,但我不清楚我的选项是什么,因为整个时间都花在向UI添加组件上。如果我经常访问UI元素,我就不能使用BackGroundWorker。那么我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2011-04-06 15:02:52

有这么多视觉效果真的那么实用吗?如果是这样的话,我会将视觉效果的添加分解,并在单独的消息中完成每个添加。换句话说,使用Dispatcher使用适当的DispatcherPriority对消息进行排队。每条消息将负责从总数中添加一小块视觉效果。

票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5562071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档