public void Start() { if (LastAction == null) { LastAction = new TickCounter(); } else { LastAction.SetNow(); } }
// Lock Memory before calling void Cleanup() { LastCleanup.SetNow(); foreach (var identpair in Memory.ToArray()) { if (identpair.Value.Value.DeltaToNow > MemorySpan) { Memory.Remove(identpair.Key); } } }
// Lock Memory before calling void Cleanup() { LastCleanup.SetNow(); foreach (var identpair in Memory.ToArray()) { while (identpair.Value.Count > 0 && identpair.Value.First.Value.DeltaToNowMilliseconds > MemorySpan.ToMilliseconds) { identpair.Value.RemoveFirst(); } if (identpair.Value.Count == 0) { Memory.Remove(identpair.Key); } } }
// Lock Memory before calling void Cleanup() { LastCleanup.SetNow(); foreach (var identpair in Memory.ToArray()) { while (identpair.Value.Any() && identpair.Value.First.Value.DeltaToNow > MemorySpan) { identpair.Value.RemoveFirst(); } if (!identpair.Value.Any()) { Memory.Remove(identpair.Key); } } }