Using QueryPerformanceCounter on a multi-core system
Posted on 2011-09-12
I need to use the Win API QueryPerformanceCounter call in my VB.NET 2008 application. The documentation I can find warns that the call result can be unreliable on multicore systems unless SetThreadAffinityMask is called to force the QueryPerformanceCounter call to always run on the same core. I'm having trouble figuring out exactly how to use GetProcessAffinityMask and SetThreadAffinityMask to accomplish this.
Can anybody offer any known-good code examples?