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...
Use GetCurrentThreadId() or ManagedThreadId() to get the thread ID:
int threadID = (int)AppDomain.GetCurrentThreadId();
int managedThreadId = Thread.CurrentThread.ManagedThreadId;
Console.WriteLine("ThreadId = " + threadID);
Console.WriteLine("ManagedThreadId = " + managedThreadId);
Have a look at Stack Overflow question Getting the thread ID from a thread.
You can use WinApi functions GetCurrentThreadId and GetThreadId
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With