private void TimerElapsed(object sender, ElapsedEventArgs e) { if (_triggers == null) { return; } HashSet <int> itemIDs = new HashSet <int>(_triggers.Select(t => t.ItemID).ToList()); List <ItemListing> itemListings = ItemAPI.GetItemListing(itemIDs); foreach (PriceTrigger trigger in _triggers) { ItemListing listing = itemListings.Find(l => l.ID == trigger.ItemID); if (listing == null) { continue; } int itemCount; ItemPrice currentPrice; if (trigger.ListingType == ListingType.BuyListing) { itemCount = listing.Buys.Quantity; currentPrice = new ItemPrice(listing.Buys.UnitPrice); } else { itemCount = listing.Sells.Quantity; currentPrice = new ItemPrice(listing.Sells.UnitPrice); } if (trigger.Trigger(trigger.Threshold, currentPrice)) { ThresholdReached(trigger.ItemID, itemCount, currentPrice, trigger.Threshold); } } }