I was using VS2008 RTM today and noticed that intellisense had slowed to a crawl since BETA 2. I did a bit of searching and didn’t really find much, but remembered an old discussion I had read about intellisense having problems with the XML documentation in BETA 1. I was able to fix the sluggish intesllisense problems by un-checking the “Generate XML Documentation” option in Project Properties -> Compile tab.
Â
Today I was working on a console application in Visual Studio 2005. It has a number of methods that take quite a long time to execute and I kept getting ContextSwitchDeadlock errors from the MDA which was really annoying me., because the code I was executing was fairly basic processing code, however because it was just prototyping stuff I knew it was dodgy, I just wanted to know if my theory was going to work. What I didn’t want was this MDA popping up every time I executed telling me that my code was trash. I knew that already. So I wanted to turn it off. This should have been pretty simple. It wasn’t.
I searched through a few articles and found some tips on either turning it off via the registry or turning it off via a config file. Surely this isn’t necessary. Why isn’t there an option in the Tools->Options list that allows you to do this? I tried both and neither worked. I did find however after much digging that you could get to the exceptions console by using the keyboard shortcut Ctrl + Alt + E. I don’t know where the menu option for this is. I’m told if you right click on your solution and select Debugging->Exceptions you can get it, but for some reason my copy of VS doesn’t have that nifty feature. That aside, if it is a genuine option that can be disabled, why the hell would you only put it in just the context menu of the Solution Explorer? Why isn’t it in the options dialog in the first place? In any case, I’m grateful that you can turn it off and by going here I found that there was a tree list and one of the nodes was Managed Debugging Assistants. I was able to turn off the MDA for ContextSwitchDeadlock by expanding the node and disabling it in the “Thrown” column.
Problem Solved!
Edit: After a bit more digging I actually found that it wasn’t my dodgy code that is causing the problem. See I wasn’t convinced that just by executing a command on a generics list of 100,000 objects that took nearly 12 minutes to complete that my code was doing anything particularly wrong. Well not really I knew that I might want to look at using an asynch thread if I ever roll this out to production and possibly process the list in batches, but the point is, I wasn’t doing anything strange in my code other than parsing a very large list of objects.
Turns out that even if I was using an asynch thread this wouldn’t solve the problem unless I caused each thread to run under 60 seconds. The problem is that because my code is processing a very large list of objects it’s punishing the CPU, and so it should. However because it’s doing this, it isn’t checking for pump messages which are important because you get important notifications from windows, but I want to process my list as quickly as possible and I don’t want to have to keep updating the message pump just so I don’t get a ContextSwitchDeadlock message. So my solution is that I need to process messages from the pump say every 100 objects that are processed in my application, which is fine, except it’s a console application. I don’t really care about how responsive the UI is or how responsive the application is. I’ve got a dual core CPU, it can smoke the daylights out of the first core, whilst I post to this blog on the second. The server it’s running on has dual quad cores. In any case at least now I know what the problem is and it won’t really cause me any problems, however if you are developing a GUI application and need to keep you apps responsive whilst doing a lot of processing, I suggest you read this blog post for tips and tricks on keeping the message pump under control.