Visual Studio 2008 New Multi-Threaded Debugging Feature

Writing

So, I was working in Visual Studio 2008 today (yeah, I know what you are thinking. I am pretty fancy) and I noticed this little bugger…

ThreadButtonUp

Hmmmm, my first thought was that it was the “add wavy lines” feature that I had been hearing so much about. So I clicked it. I mean, who wouldn’t want to add some nice wavy lines to their software? To my dismay though, this is all that happened:

ThreadButtonDown

You see? No wavy lines, it just was now highlighted. But in doing so I inadvertently hovered over it a little too long.

ThreadButtonToolTip

Ooooh, it is just for threads. Not quite as sexy, but still pretty cool. So I decided to wade in a little bit…

I quickly slapped together this amazingly clever little program:

static void Main(string[] args)
    {
      Thread newThread = null;
      for (int i = 0; i < 10; i++)
      {
        newThread = new Thread(new ThreadStart(CallMe));
        newThread.Name = "Thread" + i.ToString();
        newThread.Start();
      }
      newThread.Join();
    }
 
    public static void CallMe()
    {
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
 
      Thread.Sleep(1000);
    }

So, with this feature enabled I can now step through this program and I see each thread and what line it is currently on. In fact, if there is more than one thread on a line you will see a little plus sign next to the wavy lines:

MultipleThreads

Pretty cool. And as you can see in the program I am naming each one of these thread, so I can hover over one of these little wavy line icons and this shows up:

ThreadHover

This will let me see which threads are currently on that line. How cool is that? If I right click on the icon then a little menu pops up (which I am having a hard time getting a screenshot of) that lets me either flag or switch to one of the threads on the current line. This will let me quickly switch to a particular thread, or flag a thread for easy identification. This especially comes in handy when combined with the threads window:

 ThreadsWindow

Now we can flag a thread and then see which thread we are dealing with in the threads window. These features are really great for allowing you to track threads, freeze threads, and in general just deal with multi-threaded debugging in a much more pleasurable way than in Visual Studio 2005. Cheers!

Loved the article? Hated it? Didn’t even read it?

We’d love to hear from you.

Reach Out

Comments (3)

  1. If you liked that, you’ll love the parallel debugging add-in for Visual Studio 2008 we’ve just released – Allinea DDTLite. Fair disclosure: I work for Allinea, but I still think it’s pretty neat 🙂 If you’re interested, there’s a free 30-day trial version you could check out (www.allinea.com/ddtlite). It’d be good to hear how you get on!

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More Insights

View All