iStock_000002461629XSmallCall me crazy but I named my kids, I named my pets and heck, yes I even name my threads. Things which are important to me in life are worth naming; right? Thread names for me can be important in debug situations. When one uses the Performance Wizard and chooses to have a Concurrency Visualization profile report, specifically the Threads section the name of a thread is not used.

Historically and in the latest version of Visual Studio 2010 the profile reports ThreadMedo not show the thread names. Why?

Don’t get me wrong on this, Visual Studio Twenty Ten is a great product and light years ahead of all other versions! I look forward to having it share my cube and work computer for eight plus hours a day when it is finally released. But heck a man can dream can he?

Let us take a look at what inspires me to write this diminutive dissertation on a distilled user suggestion…

Premise

One can name threads, simply by, well naming it. Here is a code snippet below:

Thread T1 = new Thread(ThreadOne);

T1.Name = "Jabberwocky";

T1.Start();

Viola our thread is named. I cannot think of another reason for naming a thread except for debug purposes. Hey did someone mention debug?

Jabberwocky

Yep while debugging the nice little Threads window as shown above displays our named thread. But yet the Profile Performance reports do not show it. Are the two groups at Microsoft not talking to each other and sharing technology. 😉

Heck I even tried a trick to Trojan Horse a name into the profiler (Reference the Microsoft.VisualStudio.Profiler dll located in the install directory at  \Team Tools \Performance Tools\)

Thread t = new Thread(new ParameterizedThreadStart(
threadIndex =>
{
Microsoft.VisualStudio.Profiler.DataCollection.NameProfile(
"Jabberwocky",
Microsoft.VisualStudio.Profiler.ProfileLevel.Thread,
Microsoft.VisualStudio.Profiler.DataCollection.CurrentId
);

Console.WriteLine("Hello from thread " + (int)threadIndex);
}));

alas to no avail. The report still only shows the type of thread and its generic ID.

Why?

I feel that named threads might give one an edge in debugging race or deadlock conditions in code. This is a great tool which frankly could be made even better by including the actual thread names, if found in the report.

Connect Suggestion

If you find this little diatribe interesting go and put your two cents into the Microsoft Connect issue which I created:

Named Threads: Missing the Obvious on Profile Reports

Thanks for your time and well; taking a second look.

Share