Categories: Blog

Neat New Multithreaded Debugging Features in VS 2008

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:

While all the big features like JavaScript Intellisense and debugging are getting all the press, sometimes the little tweaks can certainly make your life much easier.

John Robbins

Recent Posts

8-Step AWS to Microsoft Azure Migration Strategy

Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…

3 days ago

How to Navigate Azure Governance

 Cloud management is difficult to do manually, especially if you work with multiple cloud…

1 week ago

Why Azure’s Scalability is Your Key to Business Growth & Efficiency

Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…

3 weeks ago

Unlocking the Power of AI in your Software Development Life Cycle (SDLC)

https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…

1 month ago

The Role of FinOps in Accelerating Business Innovation

FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…

1 month ago

Azure Kubernetes Security Best Practices

Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…

2 months ago