In the .NET BCL, there is a CurrentThread and a ProcessThread object. What is the difference between these?
Thanks
It is a hangover from a SQL Server project when .NET 2.0 was being designed. They pressed the CLR team really hard to break the link between the .NET Thread class and an operating system thread. They had reason to at the time, SQL Server supports "light-weight" threads that are implemented as fibers. A fiber is the Windows implementation of a "co-routine", something that was popular about 15 years ago.
The project was a bust, they couldn't get it reliable enough. Sadly, we are stuck with no easy way to map a Thread to a ProcessThread. Quite a loss. Maybe somebody, some day, will take advantage of the uncoupling, I haven't seen it done yet.
The only possible mapping you've got available now is to P/Invoke GetCurrentThreadId() inside the thread itself. That returns a TID that you can match to a ProcessThread.Id.