private static void TimerEventHandler(object source, ElapsedEventArgs e) { int c = 0; ArrayList keys = new ArrayList(); keys.AddRange(timerTable.Keys); foreach (Query q in keys) { TimerHopCount thc = (TimerHopCount)timerTable[q]; c = thc.TTL; if (c > 0) { c--; } if (c == 0) { RemoveRequest(q); } else { thc.TTL = c; } } if ((c % 4) == 0) //Log status every 1 minute { log.Info("CachedRequestCleanupTimer-EventHandler: requestTable has {0} elements, Last entry count={1}", requestTable.Count, c); } if (timerTable.Count == 0) { cTimer.Stop(); log.Info("Stopping CachedRequestCleanupTimer"); } }
public static void CacheRequest(Query q, int searchId, int hops) { lock (timerTable) { if (requestTable.Contains(q)) { requestTable[q] = searchId; timerTable[q] = new TimerHopCount(hops); } else { requestTable.Add(q, searchId); timerTable.Add(q, new TimerHopCount(hops)); } if (!cTimer.Enabled) { cTimer.Start(); log.Info("CachedRequestCleanupTimer started"); } log.Info("CacheRequest: HopCount = " + hops); } }