gpt4 book ai didi

c# - 上下文切换死锁

转载 作者:太空狗 更新时间:2023-10-29 20:17:58 25 4
gpt4 key购买 nike

当我在几秒钟后运行我的应用程序时,出现了这个异常。什么是异常以及我如何处理这个异常

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

关于c# - 上下文切换死锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8420426/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com