Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-04-05
4
Medium Priority
?
5,723 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 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