Solved

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

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

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)…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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