ContextSwitchDeadlock was detected

rctaubert

Member
Joined
Aug 22, 2004
Messages
24
Programming Experience
10+
I have a program in which I am trying to compose and write in excess of 14000 lines of text to a file. It gets to 9433 and quits. It will eventually give me the error shown below.

Can anyone explain the last sentence of the error message and perhaps give me a solution?

Thank you in advance.

Error Message
-------------
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1a05c8 to COM context 0x1a0738 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.
 

Josaph

Member
Joined
Jan 4, 2007
Messages
20
Location
Illinois
Programming Experience
5-10
Are you using threading in your application? I will not pretend to know completely the origin of the error message, but it sounds like your application is taking a long time to complete a process and you aren't sending messages to Windows letting it know that it's still working.

Threading this process to write the 14,000 lines might solve this problem for you.
 

rctaubert

Member
Joined
Aug 22, 2004
Messages
24
Programming Experience
10+
I agree, my app is taking a long time to compose and write out the 14000+ lines to the text file.

But, NO, I am not using any type of threading. I am taking the contents of a listbox and writing it to a tab deliniated text file.

What kind of messages am I supposed to send to Windows and how?????
 
Top Bottom