0

For downloading I use BackgroundDownloader. If user needs to delete a file(status = downloading), I need to cancel DownloadOperation. But I did not find method in the DownloadOperation`s list. Tell me, please, how to implement this?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63

1 Answers1

1

How can I cancel DownloadOperation?

You could cancel download easily with cancel token. You could pass CancellationToken to DownloadOperation when you start DownloadOperation

await download.StartAsync().AsTask(cts.Token, progressCallback);

If you want to cancel above DownloadOperation, you just call the following.

cts.Cancel();
cts.Dispose();

For more detail please refer BackgroundTransfer code sample.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36