我怎么能枚举在C#中的所有托管线程?

我怎么能枚举在C#中的所有托管线程?

问题描述:

是否有可能枚举在C#中的所有托管线程? Visual Studio的似乎是能够做到这一点,当你打一个破发点,同时调试。在新语丝窗口,它显示了所有正在运行的线程,包括管理的名单。有谁知道它是如何做到这一点?

Is it possible to enumerate all managed threads in C#? Visual Studio seems to be able to do this when you hit a break point while debugging. In the "Threads" window it shows a list of all running threads, including managed names. Does anyone know how it does this?

调试器往往能够做的事情正常code不能。你可能会发现,你可以做,如果你使用分析/调试API,但我不相信你可以从正常。NET code做到这一点。

Debuggers are often able to do things "normal" code can't. You'd probably find that you can do this if you use the profiling/debugging API, but I don't believe you can do it from "normal" .NET code.