Solved

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

Posted on 2007-04-05
4
5,461 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now