Replace sleep with WaitForMoreEvents

try not freeze