There are a few ways to do this. Either use a Timer, or implement some kind of polling mechanism. Which one you choose is really up to you.