ThreadMessageHandler: use semaphore instead of MilliSleep()