加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – context Switch Deadlock

发布时间:2020-12-15 08:19:06 所属栏目:百科 来源:网络整理
导读:当我在一秒钟之后运行我的应用程序时发生这种异常.什么是例外以及我如何处理这个例外 The CLR has been unable to transition from COM context 0x647f10 to COM context 0x648080 for 60 seconds. The thread that owns the destination context/apartment
当我在一秒钟之后运行我的应用程序时发生这种异常.什么是例外以及我如何处理这个例外

The CLR has been unable to transition from COM context 0x647f10 to COM
context 0x648080 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.

解决方法

如果您有阻止用户界面线程的东西,并且正在使用COM组件,则通常会发生这种情况.

这里最好的方法是将长时间运行的操作移动到后台线程中.这使您的UI响应,这也意味着COM消息可以正确泵送. BackgroundWorker是一个很好的工具.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读