How to debug and solve the "DisconnectedContext" problem?

I have a GUI application that connects to a sensor, collects data and processes it in the background using BackgroundWorker threads.

In its current form, I'm sending data to a graphical interface using ProgressChanged , which seemed to work well for a start. Since then I have increased the data transfer rate and discovered a problem; if the software remains to work for several minutes, the processor usage increases until it reaches about 100% on both cores on my machine, and at this moment I get an error message:

Remote Debugging Assistant "DisconnectedContext" has encountered a problem in "myapp.exe". Additional Information: Context 0xe2ba0 is disabled. Release interfaces from the current context (context 0xe2d10). This may result in data corruption or loss.

I read something on the Internet that says this can happen if the GUI application cannot quickly translate the messages. I noticed that I can provoke the same crash that will happen faster if I quickly resize the window (i.e. load more messages), which supports the theory I'm thinking of?

So the questions are here:

  • Does anyone agree with my hypothesis of forwarding messages?
  • Is there any other explanation?
  • Is there any way to prove this (maybe look at the number of messages in the queue)?
  • Are these bad smells of code that suggest that I am wrong?

Any advice would be greatly appreciated.

+6
debugging crash c ++ - cli
source share
1 answer

This view sounds like a very specific problem, and I think that why no one has answered yet, but I think I can help in question number 3.

Spy ++ should be able to see messages reaching your window. I think you could use it to view messages in your GUI and perform a resize test. If you notice a large number of attempts to process messages, this may confirm your hypothesis.

As an aside, I read that you could change the main thread flat from STAThread to MTAThread so that this MDA leaves.

Perphaps, you can modify your application to send sensor readings to a file or queue them in another mechanism, rather than constantly updating the GUI. NTN.

+3
source share

All Articles