in reply to Doing stuff while doing other stuff
Take a look at the docs on select. It's probably what you are seeking. It's difficult to be really sure without sight of your code.