Neither of those solutions work because it is still waiting for the sleep() to finish. This is apparent when I increase the sleep from 2 seconds to 500 seconds, which better emulates the time-intensive function that my program is doing (enumerating all files on the hard drive and adding their sizes).
Any other ideas on how to handle this?