如何调试和解决一个“DisconnectedContext”崩溃? [英] How to debug and solve a 'DisconnectedContext' crash?

查看:738
本文介绍了如何调试和解决一个“DisconnectedContext”崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GUI应用程序连接到传感器,收集数据并在后台使用 BackgroundWorker 线程处理它。



因为它的立场我使用 ProgressChanged 发布数据到GUI,它似乎运行良好开始。我已经提高了数据速率,并发现了一个问题;如果软件运行几分钟,处理器使用量似乎上升,直到它达到接近100%在我的机器上的两个核心,在这一点,我得到一个错误:


托管调试助手DisconnectedContext在myapp.exe中检测到问题。附加信息:上下文0xe2ba0已断开连接。从当前上下文释放接口(上下文0xe2d10)。这可能会导致损坏或数据丢失。


我已经读了一些网络的东西,这表明这可能发生,如果一个GUI应用程序无法足够快地泵送消息。我注意到,如果我调整窗口快速(即,泵一个负载更多的消息),支持我认为的理论,我可以引发同样的崩溃发生更快发生。



这里的问题是:


  1. 是否有人同意我关于消息抽取的假设?

  2. 另一个解释?

  3. 有一些方法我可以证明它(偷看队列中的消息数量可能)?

  4. 这些都是错误的代码气味,这表明我要走这条错误的路?

任何建议都非常感谢。

解决方案

这种听起来像一个非常具体的问题,我想这就是为什么没有人回答,但我想我可以帮助问题#3。 / p>

Spy ++ 应该能够看到到你的窗口的消息。我想你可以使用它来观察消息泵到你的GUI,并进行调整大小测试。如果您看到要处理的邮件大幅增加,可能会确认您的假设。



另外,我已经阅读了您可能可以更改主线程公寓从STAThread到MTAThread,使这个MDA消失。



Perphaps你可以修改你的应用程序,将传感器读出吐出到一个文件或排队他们在一个不同的机制,而不是不断地更新GUI。
HTH。


I have a GUI app which connects to a sensor, gathers data and processes it in the background using BackgroundWorker threads.

As it stands I'm posting data to the GUI using the ProgressChanged which seemed to be working well to begin with. I've since upped the data rates and have discovered a problem; if the software is left to run for a few minutes, the amount of processor usage appears to ramp up until it reaches near 100% on both cores on my machine and at that point, I get an error which reads:

Managed Debugging Assistant 'DisconnectedContext' has detected a problem in 'myapp.exe'. Additional Information: Context 0xe2ba0 is disconnected. Releasing the interfaces from the current context (context 0xe2d10). This may cause corruption or data loss.

I've read some stuff around the web which suggests that this can happen if a GUI app is unable to pump messages fast enough. I've noticed I can provoke the same crash to happen faster if I resize the window rapidly (i.e. pump a load more messages) which supports the theory I think?

So the questions here are:

  1. Whether anyone agrees with my hypothesis about message pumping?
  2. Whether there's another explanation?
  3. Is there some way I can prove it (peek the number of messages in the queue maybe)?
  4. Are these all bad code smells that suggest I'm going about this the wrong way?

Any advice would be very gratefully received.

解决方案

This kind of sounds like a very specific problem and I think that's why no one has answered yet but I think I can help on question #3.

Spy++ should be able to see the messages going to your window. I think you could use it to watch the messages pump to your GUI and do your resizing test. If you saw a large increase of messages trying to be processed it might confirm your hypothesis.

As an aside, I've read that you might be able to change the main thread apartment from STAThread to MTAThread to make this MDA go away.

Perphaps you could modify your app to spit the sensor readings out to a file or queue them up in a different mechanism instead of updating the GUI constantly. HTH.

这篇关于如何调试和解决一个“DisconnectedContext”崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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