Visual Studio中:ContextSwitchDeadlock [英] Visual Studio: ContextSwitchDeadlock

查看:292
本文介绍了Visual Studio中:ContextSwitchDeadlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经越来越,我解决不了的错误消息。它从Visual Studio或调试器起源。我不知道最终的错误条件是否在VS,调试器,我的程序或数据库。

I have been getting an error message that I can't resolve. It originates from Visual Studio or the debugger. I'm not sure whether the ultimate error condition is in VS, the debugger, my program, or the database.

这是一个Windows应用程序。不是Web应用程序。

This is a Windows app. Not a web app.

从VS的第一条消息是一个弹出框说:
没有符号加载任何调用堆栈帧。无法显示源$ C ​​$ C。
当被点击了,我得到:
检测到的 ContextSwitchDeadlock ,下面转载长消息一起。

First message from VS is a popup box saying: "No symbols are loaded for any call stack frame. The source code can not be displayed." When that is clicked away, I get: "ContextSwitchDeadlock was detected", along with a long message reproduced below.

在一个循环,扫描下来的DataTable发生的错误。对于每一行,它使用从表一键(HIC#)值作为一个SqlCommand的参数。该命令用来创建一个SqlDataReader返回一行。数据进行比较。如果检测到错误的行添加到第二数据表

The error arises in a loop that scans down a DataTable. For each line, it uses a key (HIC #) value from the table as a parameter for a SqlCommand. The command is used to create a SqlDataReader which returns one line. Data are compared. If an error is detected a row is added to a second DataTable.

错误似乎涉及到程序需要运行多长时间(即后60秒),许多错误都没有怎么找到。我不认为这是一个记忆的问题。无变量在循环内声明。所创建的唯一对象是SqlDataReaders,和它们在使用的结构。添加System.GC.Collect()没有效果。

The error seems to be related to how long the procedure takes to run (i.e. after 60 sec), not how many errors are found. I don't think it's a memory issue. No variables are declared within the loop. The only objects that are created are the SqlDataReaders, and they are in Using structures. Add System.GC.Collect() had no effect.

该数据库是在同一台笔记本电脑一个SQLServer网站。

The db is a SqlServer site on the same laptop.

有形式没有花哨的小玩意儿或小工具。

There are no fancy gizmos or gadgets on the Form.

我不知道在这个PROC这是从我以前做过数十次大大不同的东西。我以前看过的错误,但从来没有一个一致的基础上。

I am not aware of anything in this proc which is greatly different from what I've done dozens of times before. I have seen the error before, but never on a consistent basis.

任何想法,任何人吗?

完整的错误文本:
在CLR一直无法从COM上下文0x1a0b88过渡到COM环境0x1a0cf8 60秒。拥有目标上下文/公寓线程是最有可能要么做一个非抽水等待或处理一个很长的运行操作,而抽水Windows消息。这种情况一般具有性能产生负面影响,甚至可能导致应用程序变得无响应或内存使用量随着时间的推移不断积累。为了避免这个问题,所有单线程单元(STA)线程应该使用抽水等待原语(如CoWaitForMultipleHandles),并在长时间运行的操作常规泵的消息。

Full error Text: The CLR has been unable to transition from COM context 0x1a0b88 to COM context 0x1a0cf8 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.

推荐答案

该ContextSwitchDeadlock并不一定意味着你的code的问题,只是有一个潜在的。如果你去调试>菜单和扩大托管调试助手例外,你会发现ContextSwitchDeadlock已启用。如果禁用此,VS将不再提醒你,当项目需要很长的时间来处理。在某些情况下,可能有效有一个长期运行的操作。这也是有益的,如果你正在调试,并已停止在一条线上,而这是处理 - 你不希望它抱怨你有机会挖掘到的一个问题之前,

The ContextSwitchDeadlock doesn't necessarily mean your code has an issue, just that there is a potential. If you go to Debug > Exceptions in the menu and expand the "Managed Debugging Assistants", you will find ContextSwitchDeadlock is enabled. If you disable this, VS will no longer warn you when items are taking a long time to process. In some cases you may validly have a long-running operation. It's also helpful if you are debugging and have stopped on a line while this is processing - you don't want it to complain before you've had a chance to dig into an issue.

这篇关于Visual Studio中:ContextSwitchDeadlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆