且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Visual Studio在断点上冻结

更新时间:2023-02-27 13:34:53

我终于找到了这种奇怪行为的原因。正如我在原来的帖子中提到的,在应用程序初始化期间,我钩了键盘( AND 鼠标,我忘了我这样做),以便能够检测用户不活动。

I have finally found the cause for this weird behavior. As I mentioned in the original post I do hook the keyboard (AND mouse, I had forgotten I did that) during the application's initialization in order to be able to detect user inactivity.

监视发生在一个后台线程中,它只是等待一个 AutoResetEvent 来发现用户活动或不活动。由于某种奇怪的原因, AutoResetEvent.WaitOne(...)会以某种方式影响调试器。我当前的修复是只是避免等待,如果调试器附加。

The monitoring takes place in a background thread that simply waits for an AutoResetEvent to discover user activity or inactivity. For some odd reason the AutoResetEvent.WaitOne(...) somehow affects the debugger. My current fix is to just avoid the wait if the debugger is attached.

我仍然无法解释为什么这种情况发生。它已经工作了一年,但问题的原因终于找到并处理。

I still cannot explain why this happens now. It has been working for a year but the cause for the problem is finally found and dealt with.

我已经提交了我的问题给Microsoft,希望得到一个很好的解释。如果我这样做,我会在这里张贴。

I have submitted my question to Microsoft, hoping to get a good explanation. If I do I will post it here.