Solved

ContextSwitchDeadlock exception?

Posted on 2012-03-22
6
677 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 250 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 250 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
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…

691 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