views:

771

answers:

1

I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to know the managed name of threads started with Thread.Start. It isn't a property on the ProcessThread object though. Is there a way to get this information from a ProcessThread?

+3  A: 

While CLR spawns an OS thread for each managed thread, it's not forced to. I mean, no standard guarantees that there should be a one to one mapping between OS threads and managed threads.

To quote MSDN:

An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host can use the CLR Hosting API to schedule many managed threads against the same operating system thread, or to move a managed thread between different operating system threads.

Mehrdad Afshari
Thanks - this is the information I was looking for.
Jon Tackabury