How do I check to see if an application is runnning, if it is I just want to wait until it has completed.

Thanks