I am trying to implement Background Intelligent Transfer Service(BITS) scenario, where it downloads file from IIS server. I have implemented call back "IBackgroundCopyCallback" as well. Its working fine if there is no system failure (like
system shutdown, network issue, BITS service availability).
Scenario:
implementation is based on Windows event base, where application has to wait for get signal by call back "CBackgroundCopyCallback::JobTransferred()" function, where it also call complete() function or another call back "CBackgroundCopyCallback::JobError()".
problem:
if BITS is downloading big size file and BITS service gets stop in between, then call back JobTransferred() is not getting called, as result complete() also not getting called, so file remains as tmp file.
(temp file is not renamed (available) till IBackgroundCopyJob::Complete() function is not getting called.)
I also verified job state by printing them in call back "CBackgroundCopyCallback::JobModification()" method where last captured state is 'BG_JOB_STATE_TRANSFERRING'.
Also verified job on cmd prompt by cmd "bitsadmin /list" multiple times, where job state changed from 'TRANSFERRING' to 'TRANSFERRED'.
at last tmp file is same as remote file in size, application also remains in waiting state as it’s waiting for getting signaled by call back.
queries:
1.) how can we handle this scenario? does BITS provide some kind of API to handle this.
2.) in similar way if system get restarts in between then what is feasible way to complete that job? (as in this case application will also get terminated.)