As fang said, create a thread for this, you can manage time-based events from a single thread that way. You could also do it without a thread asynchronously but if you asked help on this one, you`re better off creating a separate thread, it will be much easier to do.