private static void FillPairCountDic(ProductPair productPair) { if (ProductPairCountDic.ContainsKey(productPair)) ProductPairCountDic[productPair]++; else ProductPairCountDic[productPair] = 1; }
public static void AddVisit(string upc1, string upc2) { lock (snycLock) { ProductPair productPair = new ProductPair() {UPC1 = upc1, UPC2 = upc2}; ProductVisitQueue.Enqueue(productPair); if (ProductVisitQueue.Count > MAX_QUEUE_LENGTH) { ProductPair dequeuedPair = ProductVisitQueue.Dequeue(); ProductPairCountDic[dequeuedPair]--; if (ProductPairCountDic[dequeuedPair] <= 0) ProductPairCountDic.Remove(dequeuedPair); } FillPairCountDic(productPair); // for performace reason, use REFRESH_THRESHOLD if (updateCounter++ > REFRESH_THRESHOLD) { updateCounter = 0; Queue2IO(); } } }