Stopwatch has a bug on multiprocessor system:
On a multiprocessor computer, it does not matter which processor the thread runs on. However, because of bugs in the BIOS or the Hardware Abstraction Layer (HAL), you can get different timing results on different processors. To specify processor affinity for a thread, use the ProcessThread.ProcessorAffinity method.
I am trying to work around that by binding a dedicated thread to a particular processor. So, let's say there are 4 processors, the current process is bound to processor 1 and 2. My code binds the thread to processor 1. But what happens when the user then binds my process to run only on processor 2 and 3? What happens to the thread that I bound to processor 1?
I tried to look into the SetThreadAffinityMask and SetProcessAffinityMask Win32 APIs (as well as the .NET Process.ProcessorAffinity and ProcessThread.ProcessorAffinity) but there is no description about this particular situation. And for some reason, there is also no GetThreadAffinityMask API....