When you say you want your app to "run in background", do you mean you want the window to be up, but other windows to be on top of it, or do you mean no gui at all for your app.
In either case, you're going to need another
thread to do this. Here's some code that shows how to make an app "sleep" for a certain number of seconds...