[ACCEPTED]-Getting the thread ID-multithreading
Accepted answer
Use GetCurrentThreadId() or ManagedThreadId() to 2 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 1 question Getting the thread ID from a thread.
If you are seeing a different thread ID 7 in your live application as opposed to when 6 you debug in Visual Studio, that is just 5 what you should expect to see, right?
When 4 running in the debugger, you are effectively 3 running the application in the debugger 2 host which will have different threads than 1 just running the application on its own.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.