c# – context Switch Deadlock

前端之家收集整理的这篇文章主要介绍了c# – context Switch Deadlock前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我在一秒钟之后运行我的应用程序时发生这种异常.什么是例外以及我如何处理这个例外

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是一个很好的工具.

原文链接:https://www.f2er.com/csharp/243144.html

猜你在找的C#相关文章