Mike, I don't want to branch off this discussion into why calling Sleep would be bad ... it's simply a way to relinquish control back to the OS instead of maxing out CPU cycles for unnecessary looping. I can only wish that more developers out there used this approach. Plus, if you look into the code I posted above, the Sleep(1) call is replaced with WaitForSingleObject(hStopEvent, 1), that I agree is a better alternative.

As the kernel synchronization goes, did you see the use of the hSharedMemMutex mutex around the function I posted?