Is there a way to get notified about new BackgroundFileTransfers?


  • I wonder if there is a notification that I can register for to detect new BFT and display them in a Listview?
    Sunday, September 30, 2012 8:42 PM

All replies

  • Not in the way you indicate. The only background transfers visible to an app are those that the app itself has initiated, so you would already have that information if you want to track it. There isn't an API to watch transfers across multiple apps.

    Within you app you can call Windows.Networking.BackgroundTransfer.BackgroundDownloader.getCurrentDownloadsAsync (and BackgroundUploader.getCurrentUploadsAsync) to retrieve a list of active transfers. The progress property of each transfer will tell you the status, so you could use such calls to refresh a list in response to a user command or one some interval (5 seconds or such).

    The other way you track progress and watch status is through the progress handler for the BackgroundDownloader/Uploader.startAsync methods--that is, the third function you pass to the then/done methods of the promise you get back from startAsync. Background transfer supports async progress, and the DownloadOperation/UploadOperation objects that are given to the progress handler will contain the same progress property that includes status. Calls to your progress handlers are effectively the events that indicate a status change, either with transfer progress (so you can update % complete) as well as completion and errors.

    Monday, October 01, 2012 4:02 PM
  • Thanks Kraig, I meant only in-app not across apps of course. So I rolled my own app API to start downloads so I can add them to my listview.

    I am using attachAsync to get real progress updates. The question now is: How do I model my listviews Datasource to reflect changes made in the progress handler?

    Monday, October 01, 2012 4:17 PM
  • Hmmm. Not something I've thought about. Seems like you'd wrap a class around the datasource with some entry points that your progress handler could call to send updates. Then the object can update the datasource to have it reflected in the bound ListView. That's about all that comes to mind at the moment.
    Tuesday, October 02, 2012 3:37 AM
  • So the listview does not actually understands the concept of observable items? I'd have expected that if the datasource contains observable items the LV would react to changes to those.
    Tuesday, October 02, 2012 9:08 AM
  • My understanding is that if you're using a WinJS.Binding.List as the datasource then you should get observable behavior. Is that what you're using?
    Wednesday, October 03, 2012 5:56 AM