I'm writing an application in C #. My application works fine by processing up to a certain amount of data. However, if this amount of data increases significantly, it enters a state called by "STOP STATE" and the following message appears:
Managed Debug Wizard 'ContextSwitchDeadlock': 'The CLR was unable to transition from the COM context 0x9e58a0 to the COM context 0x9e57e8 in 60 seconds.'
The thread that has the target context / apartment is probably waiting unpowered or processing a very long run operation without pumping Windows messages. Generally, this situation has a negative impact on performance and may even lead to the application's lack of response or the continuous accumulation of memory usage over time. '
To avoid this problem, all threads with a single apartment on thread (STA) should use pumping wait primitives (such asCoWaitForMultipleHandles
) and routinely pumping messages during long run operations. ''
In my case, the thread is performing a very long "no pumping of Windows messages" operation.
Until then, I never had to deal with it.
How can I resolve this? It may be a snippet of code (it does not have to be in C #, any pseudo code helps).