What you are looking for is a kind of multi-tasking. The solution for this are interrupts and the best resource is Darrel Taylor, http://www.pbpgroup.com/modules/wfse...php?category=4

His is the author of Instant Interrupts. Study the examples and you will have the effect you want.

Ioannis