0
I am writing an application in C#. My application works well processing up to a certain amount of data. However, if this amount of data increases significantly, it enters a state named by Visual Studio as "state of interruption" and displays the following message:
Contextswitchdeadlock Managed Debugging Wizard: 'CLR failed to transition from COM 0x9e58a0 context to COM 0x9e57e8 context in 60 seconds.`
The thread that has the target context/Apartment is probably waiting without pumping or processing a very long run operation without pumping Windows messages. Generally, this situation has a negative impact on performance and can even lead to lack of application response or to continuous accumulation of memory usage over time`.
To avoid this problem, all threads with a single thread Apartment (STA) must use pumping standby primitives (such as
CoWaitForMultipleHandles
) and routinely pump messages during long run operations.'`
In my case, the thread is performing a very long operation "no pumping of Windows messages".
Until then, I never had to deal with it.
How can I fix this? It can be a chunk of code (it doesn’t have to be in C#, any pseudo code helps).
If competition is a problem a possibility is to implement processing queues. Create a Worker that gets the 'tasks' from a FIFO queue.
– OnoSendai
Is there a way to illustrate this in code? A class?
– Paulo
This can give you a light: http://stackoverflow.com/questions/22688679/process-queue-with-multithreading-or-tasks
– OnoSendai
https://msdn.microsoft.com/en-us/library/hh228601(v=vs.110). aspx
– OnoSendai