Does anyone know if it is possible to detect when a new thread has been created in a managed environment?
I would like to have a list of all threads in my application (id and name of each thread). I am using Concurrency Visualizer in Visual Studio and it only displays thread ids (not thread names). And it's quite difficult to visualize the program flow if you have 20+ threads without their names.
EDIT:
Using Process.GetCurrentProcess()
. Threads is not OK as the CLR does not guarantee one-to-one mapping between managed and unmanaged threads.
One solution would be to create some sort of thread manager via which all thread creation would have to be done. It would also manage list of all currently alive threads.