3

I'm working on a Metro app that will upload and download some files. MS provides a couple examples: http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Upload-457ae763 http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61

The first one is an uploader app, and the 2nd is a downloader app. As Win8 can suspend and kill an app when it goes out of focus, the downloader app provides for retrieving the active downloads so I can start receiving updates about the status. The Uploader app does not. I have tried to add this functionality, but getCurrentUploadsAsync() is returning 18 transfers that I have already completed. I have tried everything I can think of to remove these transfers, but it does not change the results of getCurrentUploadsAsync().

Does anyone know how to clear out "dead" BackgroundTransfers in WinRT?

svick
  • 236,525
  • 50
  • 385
  • 514
mrbell321
  • 31
  • 2
  • I figured it out. `getCurrentUploadsAsync` returns a list of something or other... a container? which contains an `operation` object. I thought the important part was the `operation`, but you can call `cancel` on the container. A more interesting problem now is "can you restart a _dead_ transfer?" If it's not dead, you can start monitoring it again, but i haven't been able to get it to do anything interesting... – mrbell321 Nov 28 '11 at 23:43
  • Put your finding in the answer and mark it as the answer so this doesn't appear to be an unanswered question. – Jeremy Foster Aug 25 '12 at 06:44

1 Answers1

1

You have to call the cancel method like explained there : http://www.jonathanantoine.com/2013/02/05/winrt-how-to-cancel-a-background-download-operation/

theDownloadOperation.AttachAsync().Cancel();
Jonathan ANTOINE
  • 9,021
  • 1
  • 23
  • 33