1

Is there any ready collection type in C# to support this scenario:

I need to add from many threads, if the collection reached it's maximum configured capacity, it will delete the oldest item and add the new item.

Is this supported natively by some .NET 4.0 object, and if not, what is the best way to implement this?

EDIT:

I am searching in ConcurrentCollections but I couldn't find anything helpful!

Saw
  • 6,199
  • 11
  • 53
  • 104
  • 2
    You can wrap a [ConcurrentQueue](http://msdn.microsoft.com/en-us/library/dd267265%28v=vs.110%29.aspx) and expose a custom `Enqueue` method as shown here http://stackoverflow.com/questions/5852863/fixed-size-queue-which-automatically-dequeues-old-values-upon-new-enques – keyboardP Feb 01 '14 at 12:12
  • Why down-voted! please comment when down-voting to know the problem. – Saw Feb 06 '14 at 07:10
  • I'm guessing because you've been given an answer in the comment section but your edit doesn't explain why it wasn't suitable for you so there's no other answer to give. – keyboardP Feb 06 '14 at 09:56

0 Answers0