Possible Duplicate:
C#/.NET: How to get the thread id from a thread?
How I can get the same thread ID as I see it in Visual Studio?
I have tried to use Thread.CurrentThread.ManagedThreadId
, but I am getting different numbers.
I am getting 35, 38, 39, etc., but in Visual Studio I have 10596, 893, etc...
You can use WinApi functions GetCurrentThreadId and GetThreadId
Use GetCurrentThreadId() or ManagedThreadId() to get the thread ID:
Have a look at Stack Overflow question Getting the thread ID from a thread.
If you are seeing a different thread ID in your live application as opposed to when you debug in Visual Studio, that is just what you should expect to see, right?
When running in the debugger, you are effectively running the application in the debugger host which will have different threads than just running the application on its own.