Re: get real/unmanaged/kernel thread ID (not managed thread ID) for a thread
- From: Ashutosh <smbs-msdn@xxxxxxxxxxxxx>
- Date: Fri, 03 Oct 2008 08:49:36 +0530
Thanks!
My issue is resolved.
-
Ashutosh
v-jzho@xxxxxxxxxxxxxxxxxxxx wrote:
Hello Ashutosh,.
Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou [MSFT] and I will be working on this issue with you. We can get the current Thread's OSID by calling AppDomain.GetCurrentThreadId(). This function will return the same result as we call the Winows API GetCurrentThreadID() using PInvoke. But that function is deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads).
From your description, if getting the OS thread ID is for debugging and testing purpose, may I suggest to use the SOS debug extension and its !threads command in Visual Studio instead? This command will print out all managed threads' statistics information including the OSID. The following is a typical output for the !threads command and the numbers 5060/5536/5976 are the OS thread IDs:
------------------------------------------------------------------------
!threads
PDB symbol for mscorwks.dll not loaded
ThreadCount: 3
UnstartedThread: 0
BackgroundThread: 1
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
PreEmptive GC Alloc Lock
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
5060 1 13c4 0058a780 86028 Enabled 01c5a1d8:01c5bfe8 00550810 0 STA
5536 2 15a0 00558628 b228 Enabled 00000000:00000000 00550810 0 MTA (Finalizer)
5976 3 1758 005e37d8 8b028 Enabled 00000000:00000000 00550810 0 MTA
-------------------------------------------------------------------------
You can get the more detailed information about loading sos debug extension within Visual Studio from this msdn blog entry, http://blogs.msdn.com/vijaysk/archive/2007/11/15/sos-your-visual-studio.aspx
. Please let me know if my suggestion works for you or not. If you have any future questions or concerns about this, please feel free to let me know. I will do my best to follow up.
Best regards,
Ji Zhou (v-jzho@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Prev by Date: ShowDialog wont work
- Next by Date: Re: Oh my God
- Previous by thread: ShowDialog wont work
- Next by thread: Troubles with Windows Error Reporting system and Vista Logo certification (Test Case 32)
- Index(es):
Relevant Pages
|