If you’re going to lock the message manager, then there’s really no point in using a high-res timer!
Acquiring the MessageManagerLock could take any amount of time, so that’s going to screw up the timing of anything that happens in your timer thread after that point, and defeats the whole purpose of the high-res timer class!
If you’re doing something that’s time-critical then you should use the high-res timer to do all the threaded work, and then make it asynchronously post a message or AsyncUpdater or Timer or something to take care of any GUI tasks that come out of it later. That’d also avoid these deadlocks.
And in general, avoid using the MessageManagerLock at all, unless there’s really no other solution, as it’s way too easy to cause horrible deadlocks with it… Even Fabian’s suggestion above will occasionally go wrong and deadlock! And always use the MessageManagerLock constructor that takes a Thread pointer so it can fail if the thread is trying to stop.