DisconnectedContext/ContextSwitchDeadlock was detected
I have RichTextBox which I do heavy message logging from multi threads. After some time I first received the "DisconnectedContext was detected" message and I removed the breaking on exception from the Debug->Exceptions... window. But then I received "ContextSwitchDeadlock was detected". I removed this too and the UI came back to life. After some time it freezed again.
Is there a way to prevent this? Or is there a component that supports coloring, changing fonts to give a visual feedback in .NET like RichTextBox but without this error?
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x6eb0760 to COM context 0x6eb08d0 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 accumu开发者_如何学编程lating 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.
Are you sure you are updating the RichTextBox from multiple threads? If so you'd better stop that and use the UI thread to update the RTB. To do that: call theForm.BeginInvoke( delegate to a method that updates the RTB)
This should allow all the concurrent threads to continue ASAP without waiting for response.
精彩评论