创建下载 :
download = downloader.CreateDownload(source, destinationFile);
Progress<DownloadOperation> progressCallback = new Progress<DownloadOperation>(DownloadProgress);
cts = new CancellationTokenSource();
download.StartAsync().AsTask(cts.Token, progressCallback);
正常回调:
private void DownloadProgress(DownloadOperation download)
{
if (download.Progress.Status == BackgroundTransferStatus.Completed)
{
//operation
}
}
download.Progress.Status == BackgroundTransferStatus.Completed 打断点 都是可以进入, 不打断电,下载后的操作就有异常,未找到原因,所以,偷鸡搞面延迟操作,解决了,不知道哪位能解释下问题何在?
ok 代码:
private void DownloadProgress(DownloadOperation download)
{
ThreadPoolTimer.CreateTimer(async (timer) => { if (download.Progress.Status == BackgroundTransferStatus.Completed) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { //operation }); } }, TimeSpan.FromSeconds(1));
}