BackgroundDownloader.GetCurrentDownloadsAsync returns completed downloads

前端 未结 1 1410
谎友^
谎友^ 2020-12-22 00:32

In my windows store app I am using BackgroundDownloader class to handle multiple background downloads. After all my 3 downloads are 100% complete, I close and open applicati

相关标签:
1条回答
  • 2020-12-22 01:11

    You have to execute the completion handler by doing AttachAsync() on the downloads that just completed. After that, downloads will not appear anymore in the results of GetCurrentDownloadsAsync().

    Try:

    private async void Foo()
    {
        var downloads = await BackgroundDownloader.GetCurrentDownloadsAsync();
        foreach (var download in downloads)
        {
            var task = download.AttachAsync().AsTask();
            var notAwait = task.ContinueWith(OnCompleted);
        }
    }
    
    private void OnCompleted(Task<DownloadOperation> task)
    {
        DownloadOperation download = task.Result;
        // ...
    }
    
    0 讨论(0)
提交回复
热议问题