Run a function every n milliseconds.