Author Topic: ContextSwitchDeadlock  (Read 1797 times)

0 Members and 1 Guest are viewing this topic.

ReneRam

  • Guest
ContextSwitchDeadlock
« on: July 13, 2009, 07:35:11 AM »
Hi to everybody,

In one of my programs, while debugging, I get randomly the following message:

Quote
"ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1a4a50 to COM context 0x1a48e0 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."

that I assume is .Net issue. It rises only when I do operations, like block filtering with large amount of blockreferences, or similar operations in big drawings. Actually I think I am in a single threaded apartment, same function returning a collection of blockreferences.
While developing, if I just wait, the program works, but I found out the my users think the program is stuck and simply close AutoCAD from the task manager.
Any suggestions.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8805
  • AKA Daniel
Re: ContextSwitchDeadlock
« Reply #1 on: July 13, 2009, 10:04:02 AM »
maybe calling Application.DoEvents(), every so often would give things a chance to catch up .?.

ReneRam

  • Guest
Re: ContextSwitchDeadlock
« Reply #2 on: July 13, 2009, 11:36:01 AM »
Thanks Daniel,
this is exactly what I have done and it works  :-) in the debugger.
I have also added a popup form,plus progressbar, that tells the user to wait and it solves the issue at runtime.