I have a need to make a time-based dictionary hashtable that doesn't grow infinitely in size.
By "time-based", I specifically mean that if I were to add a dictionary at time X, I would like the item to not exist at X+Y time. Y being the timeout period.
I'm willing to store the time in the dictionary or as a structure in the key or value.
CONTEXT:
I get "callbacks" called by a library that we're using which gives me 4 pieces of information (time, key, value, operationType).
operationType can be start or end (there are others, but it doesn't matter).
So if I get an end within the Y time period after X, I'm happy to use this useful information. Otherwise I can discard it.
QUESTION:
Is this basically a Timer-thread that cleans up the dictionary every Y intervals, and the main thread keeps adding stuff into this dictionary from the callback?
I used Dictionary to do this, without a timer and it seemed to grow infinitely even though I removed the elements that I was able to "join".
Also, is there some sort of .NET library that does something like this?