private async Task LoadDownloads() { Downloads.Clear(); DownloadsState = ContentState.Loading; while (_downloadsService.IsLoading) { await Task.Delay(1000); } var downloads = _downloadsService.GetAllDownloads(); if (downloads == null) { DownloadsState = ContentState.NoData; return; } for (int i = 0; i < downloads.Length; i++) { Downloads.Add(new TransferItemViewModel(downloads[i], _locService)); } DownloadsState = ContentState.Normal; }
private void AllDownloadsComplete() { FilesToDownload = 0; AreDownloadStartpossible = false; AreDownloadDetailsShown = false; AreDownloadListShow = false; Downloads.Clear(); }
public DownloadsViewModel() { Title = "Downloads"; LoadItemsCommand = new Command(() => { IsBusy = true; Downloads.Clear(); RefreshDownloads(); IsBusy = false; }); }
protected override void OnClosing(DataEventArgs dataEventArgs) { base.OnClosing(dataEventArgs); foreach (var md in Downloads) { md.OnInitialized -= ModInitialized; md.OnModDownloaded -= ModDownloaded; md.OnModDownloadError -= DownloadError; if (cancellationTokenSource.IsCancellationRequested) { md.DownloadedStream?.Close(); } } Downloads.Clear(); // Ensure we have no references in event this window doesn't clean up for some reason (memory analyzer shows it is not reliable unless another window appears) }
/// <summary> /// Downloads the provided List of Feeds. /// You cannot call download while downloads are in progress. /// </summary> /// <param name="feeds">List of feeds to download.</param> public void Download(IList <Feed> feeds) { // Clear any leftover stored articles/feeds in Downloads and _allRequests. Downloads.Clear(); _allRequests.Clear(); // Set the timer for timeouts if parsing syndication feeds. if (_parser is SynFeedParser) { int timeLimit; if (Settings.InitialLaunchSetting) { timeLimit = 20000; // 20 second limit for initial launch. } else { timeLimit = 7500; // Otherwise, 7.5 second time limit. } TimerCallback tc = new TimerCallback(TimeoutConnections); _timeout = new Timer(tc, this, timeLimit, Timeout.Infinite); } if (null != feeds && feeds.Count > 0) { lock (_lockObject) { _numOfRequests += feeds.Count; } IsDownloading = true; // Download each separate feed. foreach (Feed feed in feeds) { string feedURI = feed.FeedBaseURI; if (null != feedURI) { HttpWebRequest feedRequest = HttpWebRequest.Create(feedURI) as HttpWebRequest; // Check if the application has been set to wifi-only or not. if (WifiOnly) { feedRequest.SetNetworkRequirement(NetworkSelectionCharacteristics.NonCellular); } if (null != feedRequest) { RequestState feedState = new RequestState() { // Change the owner to the parent HTTPWebRequest. Request = feedRequest, // Change the argument to be the current feed to be downloaded. Argument = feed, }; // Begin download. feedRequest.BeginGetResponse(ResponseCallback, feedState); // Keep track of the download. _allRequests.Add(feed, feedRequest); } } } } }