When I use
int threadnum = Thread.CurrentThread.ManagedThreadId;
it returns a value which can exceed the number of logical cores. Of course this is because there can be way more threads than logical cores. The code line isn't what I'm looking for.
What I would like, at least for a given run of the program, is a way to get which logical core the thread is running on. So if there are 48 logical cores, I would like to know which of those cores the thread was running on.
Not sure if the system numbers the logical cores in a consistent way, but at the least for a given run of the program, I would like to know which logical core a thread was running on.
With openMP in C++ it was simple: omp_get_thread_num()
The thread number of the thread team would at least be numbered from 0 to the number of logical cores - 1.