I'm using URLDownloadToFile() to download update files for my game. The function is synchronous, so I have it running in a separate thread, and I use a IBindStatusCallback (specifically the onProgress() function) to handle the progress bar, and cancelling. It seems to be working great.
Right now I'm working on timeout mechanisms so that the download will cancel if it hangs. So, during testing I thought I'd interrupt the download by disconnecting my internet. When I do this, the download completely freezes, seemingly forever. URLDownloadToFile never returns. Worse, the IBindStatusCallback::onProgress() function doesn't ever get called again. This means I have no way of telling the process to cancel.
If the connection is restored, sometimes the download recovers, but other times it doesn't and just sits there forever.
This makes me think that I shouldn't even be using this technique in the first place, but it's just so simple and functional other than this issue. Is there a way around this problem?
I'm developing on Windows 7, and I have read while Googling that this issue may appear for some versions of Windows but not for others...
EDIT: Possibly worth mentioning is that this function is included in the URL Moniker set of Internet Explorer Platform APIs (in Urlmon.lib). It's possible that there is some separate function in the API or command that I could use to cancel the download or fix the problem another way.