C# .NET - Buffer messages w/Timer
I need to implement a message buffering system that is also timed based. What I need to do is store instances of my class and then send them forward either when I reach 100 instances or when 1 minute has passed. Basically: List<Message> messages; public void GotNewMessage(Message msg) { messages.add(msg); if (messages.count() == 100 || timer.elapsed(1 minute)) { SendMessages(messages); messages.clear() } } I just can't seem to figure out how to implement this without an excessive use of locks which will slow down the process considerably. Does anyone know of a good way to implement such a