?
Solved

ContextSwitchDeadlock exception?

Posted on 2012-03-22
6
Medium Priority
?
678 Views
Last Modified: 2012-03-22
I got  the following exception, ContextSwitchDeadlock:
"The CLR has been unable to transition from COM context 0x3422fb0 to COM context 0x3423120 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."

Anybody any experience with this exception?
0
Comment
Question by:Labelsoft
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 total points
ID: 37752037
Are you doing any long running tasks within an event handler of your form?
0
 
LVL 3

Author Comment

by:Labelsoft
ID: 37752041
Yes, I am. Could that long running task prevent the form from pushing windows messages?
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 37752332
Yes it can.  If you have a long process to run, or a blocking call, then put it on a different thread.  The BackgroundWorker() control can make this task much easier:
http://msdn.microsoft.com/en-us/library/8xs8549b.aspx
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37752339
*If you have have a long running LOOP, then a "quick fix" is to place Application.DoEvents() INSIDE that loop to pump the message queue.  Properly threading the solution is a better approach though.
0
 
LVL 3

Author Closing Comment

by:Labelsoft
ID: 37752393
Kaufmed already hinted me to the 1st solution Idle-mind gave. As I was waiting for kaufmed, I implemented the backgroundworker and it worked. So I'm awarding both with points. Thank you both very much for replying.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37752735
Sorry, I was on my way to work. Glad you got it sorted out  : )
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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