Link to home
Start Free TrialLog in
Avatar of Labelsoft
LabelsoftFlag for Netherlands

asked on

ContextSwitchDeadlock exception?

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?
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Labelsoft

ASKER

Yes, I am. Could that long running task prevent the form from pushing windows messages?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
*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.
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.
Sorry, I was on my way to work. Glad you got it sorted out  : )