private async Task HandleDownloadAsync(DownloadOperation download, bool start) { DownloadViewModel Selected = Downloads.FirstOrDefault(p => p.Address == download.RequestedUri.ToString()); try { // LogStatus("Running: " + download.Guid, NotifyType.StatusMessage); // Store the download so we can pause/resume. // activeDownloads.Add(download); Progress <DownloadOperation> progressCallback = new Progress <DownloadOperation>(DownloadProgress); if (start) { // Start the download and attach a progress handler. await download.StartAsync().AsTask(cts.Token, progressCallback); } else { // The download was already running when the application started, re-attach the progress handler. await download.AttachAsync().AsTask(cts.Token, progressCallback); } ResponseInformation response = download.GetResponseInformation(); // GetResponseInformation() returns null for non-HTTP transfers (e.g., FTP). string statusCode = response != null?response.StatusCode.ToString() : String.Empty; // download completed Selected.Status = "decompressing..."; Selected.IsDownloadVisible = false; // Unzip var zipFile = await ApplicationData.Current.LocalFolder.GetFileAsync(Selected.FullFileName); var unzipFolder = await FileHelper.GetFolderNotNullAsync( ApplicationData.Current.LocalFolder, "cards"); await ZipHelper.UnZipFileAsync(zipFile, unzipFolder); // end Selected.Complete(); } catch (TaskCanceledException) { // LogStatus("Canceled: " + download.Guid, NotifyType.StatusMessage); } catch (Exception) { if (Selected != null) { await Selected.Delete(); } } finally { // activeDownloads.Remove(download); } }