views:

108

answers:

4

While debugging a .NET Framework 3.5, WinForms application I spotted some "Worker Thread"s without a name.

I know when you open an application you've got a one worker thread by default. However in the middle of debugging when I pause the debugger and take a look at the "Threads" window I see about 5+ similar threads (priority=normal).

All the threads opened by the application got a name, so these are not opened from the code, at least not via Thread.Start()

When I try to double click, VS.NET can't locate the code either.

What are these threads? Are they normal, or does some operations somehow leaves empty threads behind?

Can they be Timers or similar non obvious controls, functions works with temporary threads in the background?

A: 

If I'm reading your question right, they are threads used by the VS debugger to keep track of the operations of the various threads and other items of debugging interest. They sit inside the process to simplify analysis of that process.

Rushyo
A: 

Continuing on Rushyo's post, these threads can be related to how Visual Studio hosts and debugs your program (have you tried running a release build from outside Visual Studio and using Process Explorer to scrutinize).

If not explicitly part of VS hosting, they are probably related to the .NET thread pool, being used for timers, asynchronous method invocations.

Cecil Has a Name
+5  A: 

I just compared threads in VS with threads in WinDbg and it appears that VS labels thread pool threads as "Worker Thread" in the threads window. Thus, I would assume that what you're seeing are threads started because of use of BackgroundWorker, Timer, BeginInvoke or similar thread pool features.

Brian Rasmussen
A: 

On point where windows adds threads to your application is when you call GetOpenFileName() (or other functions that raise a ppen/save File Dialog.

Windows does the Drive/Folder Scans in the background and it obviously keeps the threads alive after closing the dialog. I just found this out by trials quite a while ago. Probably there are more points like this.

RED SOFT ADAIR
That's quite interesting
dr. evil