Added sleep if no event in queue.