locked
ContextSwitshDeadlock pain in the rear RRS feed

  • Question

  • ContextSwitchDeadlock was detected
    Message: The CLR has been unable to transition from COM context 0x1b0a08 to COM context 0x1b0b78 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.

    When I pause processing, and go into the immediate window to try something, I have 60 seconds before execution effectivly hangs, which makes debugging frustrating, to say the least.

    Can anybody tells me what this nonsense means?  I have a little app reading a file, no thread, no timers, nothing more complicated than basic data processing.

    Thanks

    Thursday, August 24, 2006 8:39 AM

Answers

  • The message that you are getting is originated by the managed debugging assistants. It is a feature of the CLR that helps detect difficult to diagnose problems, however sometimes they give false positives.

    If you are sure that your code is not deadlocked, or doing anything incorrectly, you can disable the managed debugging assistant (via the registry) by following the insturctions on this link:

    http://msdn2.microsoft.com/en-us/library/d21c150d.aspx

    Hope this helps,

     

    Friday, August 25, 2006 6:26 PM
    Moderator

All replies

  • The message that you are getting is originated by the managed debugging assistants. It is a feature of the CLR that helps detect difficult to diagnose problems, however sometimes they give false positives.

    If you are sure that your code is not deadlocked, or doing anything incorrectly, you can disable the managed debugging assistant (via the registry) by following the insturctions on this link:

    http://msdn2.microsoft.com/en-us/library/d21c150d.aspx

    Hope this helps,

     

    Friday, August 25, 2006 6:26 PM
    Moderator
  • This procedure didn't work with VBE2005.

    It did lead me to another helpful tip for something else I'm working on though.

    Ted

    Wednesday, November 1, 2006 11:55 AM
  • i will second that. no use at all.
    Thursday, November 9, 2006 6:12 PM
  • This answer is not only non-informative, but misleading to the point of making the issue worse.

    Disabling the MDA will supress the exception in the debuggin environment, but thats equivalent to having a try catch block eat an error silently.  Once the application is in a release environment, ignoring the ContextDeadlockException is going to create a mysterious and difficult to diagnosis 'memory leak' that probably won't be where you are looking for it and which will resist normal techniques for ensuring memory is freed.

    Simply put, this exception is warning the user that .Net garbage collection is suspended because a thread is running that blocks the normall message/event cycle of a windows application.  To avoid these difficulties, you should run long running processes in a background thread and ensure that they reutinely message the containing form. 

    Monday, January 3, 2011 7:24 PM