Управляемый поток имеет переменную-член m_ManagedThreadId
0:000> !do 02f34b84
Name: System.Threading.Thread
MethodTable: 5259ffcc
EEClass: 522d8ed8
Size: 48(0x30) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
52588a28 4000720 4 ....Contexts.Context 0 instance 02f7dc78 m_Context
5259b468 4000721 8 ....ExecutionContext 0 instance 02f3d4d4 m_ExecutionContext
5259f9ac 4000722 c System.String 0 instance 00000000 m_Name
5259fe80 4000723 10 System.Delegate 0 instance 00000000 m_Delegate
525a63a4 4000724 14 ...ation.CultureInfo 0 instance 00000000 m_CurrentCulture
525a63a4 4000725 18 ...ation.CultureInfo 0 instance 00000000 m_CurrentUICulture
5259f5e8 4000726 1c System.Object 0 instance 00000000 m_ThreadStartArg
5259aa2c 4000727 20 System.IntPtr 1 instance 4b6c18 DONT_USE_InternalThread
525a2978 4000728 24 System.Int32 1 instance 2 m_Priority
525a2978 4000729 28 System.Int32 1 instance 1 m_ManagedThreadId
m_ManagedThreadID соответствует «ID» в выводе! Threads
0:000> !t
ThreadCount: 17
UnstartedThread: 0
BackgroundThread: 9
PendingThread: 0
DeadThread: 7
Hosted Runtime: no
PreEmptive GC Alloc Lock
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
0 1 390 004b6c18 6020 Enabled 0d98d408:0d98e080 004a85c8 0 STA
4 2 790 004c5028 b220 Enabled 00000000:00000000 004a85c8 0 MTA (Finalizer)
5 3 15e4 00555fd0 b220 Enabled 00000000:00000000 004a85c8 0 MTA
XXXX 5 060c27d8 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
7 6 84c 060c41f0 200b220 Enabled 00000000:00000000 004a85c8 0 MTA
14 7 1aec 0611a760 200b220 Enabled 00000000:00000000 004a85c8 1 MTA
17 8 ea0 08c787c8 200b220 Enabled 00000000:00000000 004a85c8 0 MTA
XXXX 9 0b409580 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
XXXX a 08cee2d0 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
XXXX b 08ceebc8 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
XXXX c 0b409a78 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
XXXX d 0b40a248 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
XXXX e 0b40b218 19820 Enabled 00000000:00000000 004a85c8 0 Ukn
20 f 16d0 08cc1ad0 8009220 Enabled 00000000:00000000 004a85c8 0 MTA (Threadpool Completion Port)
21 10 1ab4 0b4163f0 1009220 Enabled 0d9601ac:0d962080 004a85c8 0 MTA (Threadpool Worker)
22 11 1924 0b40ef88 1009220 Enabled 0d9036c8:0d905554 004a85c8 0 MTA (Threadpool Worker)
23 4 14d8 0b416ce0 100a220 Enabled 00000000:00000000 004a85c8 0 MTA (Threadpool Worker)
А вот простой сценарий для дампаобъект управляемого потока и его идентификатор
.foreach ($t {!dumpheap -mt 5259ffcc -short}) { .printf " Thread Obj ${$t} and the Thread Id is %N \n",poi(${$t}+28) }
Вот вывод из вышеупомянутого .foreach
0:000> .foreach ($t {!dumpheap -mt 5259ffcc -short}) { .printf " Thread Obj ${$t} and the Thread Id is %N \n",poi(${$t}+28) }
Thread Obj 02f34b84 and the Thread Id is 00000001
Thread Obj 02f3d44c and the Thread Id is 00000003
Thread Obj 02f5f180 and the Thread Id is 00000005
Thread Obj 02f5f504 and the Thread Id is 00000006
Thread Obj 02f87780 and the Thread Id is 00000007
Thread Obj 03bdf8d8 and the Thread Id is 0000000C
Thread Obj 03bdff54 and the Thread Id is 00000008
Thread Obj 03d23f48 and the Thread Id is 00000009
Thread Obj 03d2491c and the Thread Id is 0000000A
Thread Obj 03d24a5c and the Thread Id is 0000000B
Thread Obj 03d24d34 and the Thread Id is 0000000D
Thread Obj 03d24ed8 and the Thread Id is 0000000E
Thread Obj 03d2bd24 and the Thread Id is 00000010
Thread Obj 03e48300 and the Thread Id is 00000002
Thread Obj 08f12f90 and the Thread Id is 00000011