public async Task StartPolling(CancellationToken cancellationToken, IEnumerable <string> selectedItems) { MainWindow mainwindow = (MainWindow)Application.Current.MainWindow; mainwindow.CollectionGrid.Items.Clear(); MostRecentListing.RootObject currentListings = await GetRecentListingsAsync(); MostRecentListing.RootObject outdatedListings = null; var ListingsToCheck = currentListings.Payload.SellOrders.Take(25).ToList(); await Task.Delay(1000); while (!cancellationToken.IsCancellationRequested) { await GetSellOrdersAsnyc(ListingsToCheck, selectedItems, cancellationToken); await Task.Delay(_pollDelay); outdatedListings = currentListings; currentListings = await GetRecentListingsAsync(); ListingsToCheck = currentListings.Payload.SellOrders .Take(300) .Where(d => outdatedListings.Payload.SellOrders .Take(300) .All(t => t.Id != d.Id)) .ToList(); } }
public async Task <MostRecentListing.RootObject> GetRecentListingsAsync() { string data = await Request.GetAsync("https://api.warframe.market/v1/most_recent"); MostRecentListing.RootObject rootobject = JsonConvert.DeserializeObject <MostRecentListing.RootObject>(data); return(rootobject); }