Get the current thread ID in c#?
-
Hello, I have a c# assembly that gets called by unmanaged code (it gets called by Internet Explorer, like a plugin). What I want to know is, how do I get the thread ID of the current thread? If I use System.Threading.Thread.CurrentThread, I can only get the name. As I understand it, C# threads are not the same thing as old win32 threads. But since my C# assembly is being called by unmanaged code, it is definately running on one of those win32 threads, how do I get the thread ID? thank you "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx
-
Hello, I have a c# assembly that gets called by unmanaged code (it gets called by Internet Explorer, like a plugin). What I want to know is, how do I get the thread ID of the current thread? If I use System.Threading.Thread.CurrentThread, I can only get the name. As I understand it, C# threads are not the same thing as old win32 threads. But since my C# assembly is being called by unmanaged code, it is definately running on one of those win32 threads, how do I get the thread ID? thank you "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx
-
Hello, I have a c# assembly that gets called by unmanaged code (it gets called by Internet Explorer, like a plugin). What I want to know is, how do I get the thread ID of the current thread? If I use System.Threading.Thread.CurrentThread, I can only get the name. As I understand it, C# threads are not the same thing as old win32 threads. But since my C# assembly is being called by unmanaged code, it is definately running on one of those win32 threads, how do I get the thread ID? thank you "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx
Well Thread.GetHashCode Will but as you guessed its a managed thread ID which isnt a win32 id because really it runs in appDomains and other factors. The key word is managed AKA hosted
**Note** An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host can use the fiber API to schedule many managed threads against the same operating system thread, or to move a managed thread between different operating system threads.
hope this helps I'm not an expert yet, but I play one at work. Yeah and here too. -
Hello, I have a c# assembly that gets called by unmanaged code (it gets called by Internet Explorer, like a plugin). What I want to know is, how do I get the thread ID of the current thread? If I use System.Threading.Thread.CurrentThread, I can only get the name. As I understand it, C# threads are not the same thing as old win32 threads. But since my C# assembly is being called by unmanaged code, it is definately running on one of those win32 threads, how do I get the thread ID? thank you "Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read." -Groucho Marx