Description
Description
I got here because I needed a unique identifier for the current thread for the entire hosting computer not the current process.
AppDomain.GetCurrentThreadId() is implemented as Environment.CurrentManagedThreadId in .NET Runtime.
I understood the obsolete message; tracked down BeginThreadAffinity and EndThreadAffinity; then concluded it doesn't even matter because our codebase is already very intolerant of fibers due to a long-running P/Invoke function (Select) called from all over the place so we already know we're not using that.
Note the documentation still says it returns the current native thread id.
Reproduction Steps
Test has a chance of false positive
Assert(System.AppDomain.GetCurrentThreadId() != System.Threading.Thread.GetCurrentThread.ManagedThreadId);
Expected behavior
Get the native thread id; in this case for a cross-process unique identifier of the current thread within the host computer; I didn't intend to actually call OpenThread with the id.
Actual behavior
Gets an ID that collides with other processes on the same computer.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response