|Think about Loose Coupling|
An option I like to use in situations like this is to send a mail when the work is done. I know it's not an ideal solution, but it is used fairly often in bioinformatic web programs (which I assume is your field)
The trick in this case is to fork the process so that the child process does all the work while the father process prints the output message (e.g. a mail will be sent...)
If this is an option, I can give you some more code for the fork process
Good luck with your research
Real programmers don't comment their code. It was hard to write, it should be hard to understand and even harder to modify.