You could put all the code you need to pause into a thread. Then you have full control of stopping ,pausing, sleeping, and/or starting the thread when you need to.