How can I get managed threads from Process.GetCurrentProcess().Threads

前端 未结 1 1710
一生所求
一生所求 2021-01-25 09:18

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 t

相关标签:
1条回答
  • 2021-01-25 09:44

    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.

    0 讨论(0)
提交回复
热议问题