Solved

Error : Context Switch Deadlock was detected ..not able to debug how to fix

Posted on 2007-04-05
4
5,578 Views
Last Modified: 2013-11-07
I get this error if i am debugging thru my VB application
Context Switch Deadlock was detected ..
The CLR has been unable to transition from COM context 0x1a0950 to COM context 0x1a0ac0 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.

0
Comment
Question by:pras_gupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
kerryw60 earned 200 total points
ID: 18859986
0
 
LVL 23

Assisted Solution

by:Christopher Kile
Christopher Kile earned 50 total points
ID: 18860017
At the beginning of every loop, throw in the VB equivalent of CoWaitForMultipleHandles():

DoEvents

to make sure your VB app releases control to Windows on a regular basis.  For loops with lots of code to execute, intersperse a few more among the code calls.  Otherwise, compute-intensive processes in VB can block tasks that a VB program is linked to from communicating back to the program or to other associated tasks (such as the CLR).  
0
 
LVL 1

Author Comment

by:pras_gupta
ID: 18860079
kerryw60 's solution in second link work...i am not aure if i can implement the other suggestions .. please help me understanding the pros of that
Goto Debug | Exceptions | Managed Debug Assistants | ContextSwitchDeadlock.
Make sure this is unchecked. Test the application and let me know the
results.
0
 

Expert Comment

by:Thiruvarul
ID: 26521116
If your application hangs or not reponse even after you uncheck the box against ontextswitchdeadlock. Put the following line before call of method or for loop.
In C#
System.Windows.Forms.Application.DoEvents();
and
VB.NET / VB / ASP.NET
DoEvents()
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question