If you run into the ContextSwitchDeadlock issue, it doesn’t mean your code is actually broken. You can actually turn this exception off through the settings menu of Visual Studio. You have a couple of options when it comes to fixing this issue!
This is the error I received:
Managed Debugging Assistant 'ContextSwitchDeadlock' :
There are two simple fixes for this issue, the first is to simply turn the option creating this error message in visual studio.
To turn this option off you need to go to exception settings by clicking Debug -> Windows -> Exception Settings
After that we need to expand
Managed Debugging Assistants and uncheck
The other option is going to be just adding
Application.DoEvents() to the section of code that is locking up the application and not pumping messages anymore. This way the system will know that the application hasn’t crashed and is still continuing to work properly.
Whichever way you solve the issue, I hope this guide helped! Thanks for reading and I’ll see you in the next one!