Desactivar ContextSwitchDeadlock

Visual Studio LogoCuando trabajamos en Visual Studio en una aplicación de cálculo intensivo puede aparecer la excepción ContextSwitchDeadlock was detected
Si lo ejecutamos desde Visual Studio, nos permite hacer «OK» o «Continue«…
si le damos «Continue«, se desarrolla sin problemas.

Message: The CLR has been unable to transition from COM context 0x1a70a0 to  COM context 0x1a6f30 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.

Esto pasa en Debug porque un thread COM queda como dice el mensaje esperando algún mensaje que obviamente al estar debugeando nadie le manda. Esto es un tema conocido y solo sucede si tenés habilitado los Managed Assistant del Visual Studio. Si deshabilitas esta «ayuda» no volverá a aparecer este mensaje.

Desactivar ContextSwitchDeadlock

[bctt tweet=»Como desactivar el ContextSwitchDeadlock en Visual Studio»]

Para desactivar el ve al menú

Debug > Exceptions > Managed Debugging Assistants > ContextSwitchDeadlock

Desactivar ContextSwitchDeadlock

 

Deja un comentario