?
Solved

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

Posted on 2007-04-05
4
Medium Priority
?
5,757 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 600 total points
ID: 18859986
0
 
LVL 23

Assisted Solution

by:Christopher Kile
Christopher Kile earned 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

862 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