Neat New Multithreaded Debugging Features in VS 2008

12 Comments August 1, 2007

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.


12 Comments

  • Gravatar Image
    SQL Server 2005 and .NET Development Blog August 2, 2007 1:09 AM

    Verbessertes Debugginghttp://www.wintellect.com/cs/blogs/jrobbins/archive/2007/08/01/neat-new-multithreaded-debugging-features-in-vs-2008.aspx

  • Gravatar Image
    Jason Haley August 2, 2007 10:24 AM

  • Gravatar Image
    ScottGu's Blog August 30, 2007 3:45 AM

    Here is the latest in my link-listing series . Also check out my ASP.NET Tips, Tricks and Tutorials page

  • Gravatar Image
    Judah August 30, 2007 11:03 PM

    Cool, thanks for this info. I've always thought the VS debugging was lacking when it came to parallel programming. It's nice to see these improvments.

  • Gravatar Image
    From the software development trenches August 31, 2007 1:32 AM

    Time for another weekly roundup of news that focuses on .NET and general development related content

  • Gravatar Image
    Scott Hanselman's Computer Zen September 21, 2007 7:24 PM

  • Gravatar Image
    Mitch Wheat September 21, 2007 11:35 PM

    Hey, great info. Looking forward to using this feature in VS 2008

  • Gravatar Image
    ASPInsiders October 3, 2007 11:07 PM

    Here is the latest in my link-listing series . Also check out my ASP.NET Tips, Tricks and Tutorials page

  • Gravatar Image
    From the software development trenches October 31, 2007 6:20 PM

    I'm currently trying to pro-actively drive the adoption of the .NET Framework 3.5 and VS 2008 within

  • Gravatar Image
    Abhijeet Rajwade February 26, 2008 4:45 AM

    This is really helpful information. Thanks

  • Gravatar Image
    bpo April 25, 2008 1:10 AM

    Really appreciate it., thanks,

  • Gravatar Image
    Mark O'Connor September 25, 2008 11:04 AM

    Nice summary of the new VS2008 thread features. We've written an parallel debugging add-in (Allinea DDTLite) for VS2008 that adds a lot of cool things for multi-threaded and multi-process debugging - easy group/individual control, variable comparisons and so on. There'a a free 30-day trial at www.allinea.com/ddtlite, so have some fun with it and let me know what you think!

Have a Comment?

Archives