我在 Windows 商店应用程序中使用文档下载器,但我遇到了任务问题。所以这是我的代码示例:
任务创建并开始
...
HttpDownloader httpDownloader = new HttpDownloader(server);
Action<object> action = (object doc ) => httpDownloader.DownloadDocument((Document)doc);
Task t1 = new Task(action,selection.doc);
t1.Start();
...
下载文件方法
...
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Application/pdf", new List<string>() { ".pdf" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = doc.name+"_"+doc.version;
StorageFile file = await savePicker.PickSaveFileAsync(); // Here an exception is launch.
...
每次我得到:
未找到元素(HRESULT 异常:0x80070490)
没有任务,我的代码工作正常,但由于我想使用任务来管理不同的下载,我有这个错误。