本文介绍了如何从Process.GetCurrentProcess().Threads获取托管线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以从Process.GetCurrentProcess().Threads获取正在运行的线程的列表,但是我需要知道以Thread.Start开头的线程的托管名称.它不是ProcessThread对象的属性.有没有办法从ProcessThread获取此信息?
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?
推荐答案
尽管CLR为每个托管线程生成了一个OS线程,但这并不是强制性的.我的意思是,没有标准保证OS线程和托管线程之间应该存在一对一的映射.
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.
引用MSDN:
这篇关于如何从Process.GetCurrentProcess().Threads获取托管线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!