本文翻译自:Getting the thread ID from a thread
In C# when debugging threads for example, you can see each thread's ID. 例如,在调试线程的C#中,您可以看到每个线程的ID。
I couldn't find a way to get that same thread, programmatically. 我无法通过编程方式找到获得相同线程的方法。 I could not even get the ID of the current thread (in the properties of the Thread.currentThread
). 我甚至无法获取当前线程的ID(在Thread.currentThread
的属性中)。
So, I wonder how does Visual Studio get the IDs of the threads, and is there a way to get the handle of the thread with id 2345
, for example? 所以,我想知道Visual Studio如何获取线程的ID,有没有办法获得id为2345
的线程句柄?
#1楼
参考: