locked
BackgroundDownloader completion missed

    Question

  • Hi

    I am wondering if it is possible to miss a BackgroundDownloader completion in this scenario:

    - A Backgroundownloader is started
    - The Application is suspended as the download is just finishing
    - Application cannot handle the end of download because it has already called SuspendingDeferral.Complete
    - The aplication is then Terminated

    At restart, the download cannot be re-attached (GetCurrentDownloadsAsync won't provide it as it was finished), it is therefore not possible to know if it was successfully completed.

    I am downloading multiple files at once which would increase the probability if it exists.

    Regards

    Charles


    Tuesday, February 10, 2015 7:13 AM

All replies

  • Hi Charles,

    Thank you for posting here, but I think it’s impossible because background transfer runs separately form the calling app. I tried to reproduce your scenario with this sample, https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61/, but it seemed ok. I switched to start screen when the downloading process was close to 100%, and resumed after 5 second, the app showed that the download process was completed. If you does not enumerate the background task to the current session when resuming app, they will remain incomplete and continue to occupy resources. So it’s recommend to check the download process when resuming app.

    If you find something about this possibility, you are welcome to post here.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.




    Wednesday, February 11, 2015 6:07 AM
    Moderator
  • Hi Herro,

    Many thanks for your response.

    I have just done some additionnal verification. It appears that a download that is completed while the application is suspended will not enumerate at application restart.

    I launch a backgroundDownload, then suspend the application, then let the download finish, then terminate the App.

    When I re-launch the App, it appears that the download will not enumerate at restart (using BackgroundDownloader.GetCurrentDownloadsAsync();)

    It was not clear in the documentation to me as it says only :

    "Calling this method allows an app to attach download operations that were started in a previous app instance."

    It looked more logical that a download that completes whithout being served by a completion Handler would enumerate at restart and trigger immediatly the completion Handler.

    Without this, you cannot know for sure if the download was successfull or not.

    One way to overcome this is to save a list of downloads you have launched (OnSuspending). Then at restart if some downloads do not enumerate you have to assume they completed correctly.

    But do we know for sure that a download that fails while the app was suspended before being terminated will always attach at restart ? And in this case why not attaching successfull downloads ?

    Regards

    Charles

    Edit : this can be reproduced easily while in the VS environnement (triggering the suspension / termination from the debug toolbar) but apparently the application behaves correctly outside of VS.

    Wednesday, February 18, 2015 11:10 PM