Sometimes the little features can make a world of difference. The VS 2008 debugger adds some help to those of us dealing with many threads running in our applications. The first is Show Threads in Source, which you can turn on either by selecting it from the context menu in the Threads window or the toggle button on the Debug toolbar (it's the one with the wavy lines and plus sign). Once Show Threads in Source, you'll see some new icons in the editor margin as shown below.
If you look closely, the breakpoint sphere has the squiggly lines through it. Below the current location marker, you also see the squiggly lines. When you mouse over those items, the debugger tells you which threads are currently executing that location. The grey on the source code lines, also help you see that another thread is executing that location. In the screen shot, it's showing the three threads I've named, using Thread.CurrentThread.Name in my code. Just being able to see what threads are also executing at that location at a glance is extremely nice.
While naming your threads in your code is very useful, it's a bit problematic as a thread can only be named once or it throws an InvalidOperationException. What would be better is if you could set the thread name in the debugger so you don't have to add the naming to your code. VS 2008 now allows us to do the thread naming simply by selecting the thread in the Threads window and starting to type. You can also right click in the Thread window and select Rename. The following shows the renamed threads in the Threads window.
You also see more color in the Threads window, with the Main and Worker threads obvious at a glance. The last new multithreaded debugging feature is also shown in the screen shot above; flagging interesting threads. As .NET applications in particular have threads running all over the place, it sometimes gets hard to monitor just a few key threads. Once you flag a thread in the Threads window, the very underutilized Debug Location toolbar has a new button to show only the interesting threads. The quick Windows Forms program I tossed together to look at these new features has 12 threads running when doing managed debugging. Since I only care about five of those threads, it's super easy to monitor them now.
As an added bonus, I wanted to point out one other new feature I stumbled across and have wanted for a long time. If you right click on a folder, project, or solution in Solution Explorer, you'll see a new menu item show up: