Threadsafe foreach enumeration of lists

后端 未结 11 1613

I need to enumerate though generic IList<> of objects. The contents of the list may change, as in being added or removed by other threads, and this will kill my enumerati

11条回答
  •  猫巷女王i
    2020-12-17 19:19

    You'll find that's a very interesting topic.

    The best approach relies on the ReadWriteResourceLock which use to have big performance issues due to the so called Convoy Problem.

    The best article I've found treating the subject is this one by Jeffrey Richter which exposes its own method for a high performance solution.

提交回复
热议问题