I have System.Collections.Generic.List _myList and many threads can read from it or add items to it simultaneously. From what I've read I should using 'BlockingCollection' so this will work. I also read about ReaderWriterLockSlim and lock, but I don't figure out how to use them instead of BlockingCollection, so my question is can I do the same with:
- ReaderWriterLockSlim
- lock
instead of using 'BlockingCollection'. If YES, can you please provide simple example and what pros and cons of using BlockingCollection, ReaderWriterLockSlim, lock?
UPDATED readers will be much more than writers!
ReaderWriterLockSlim:lock:Monitorclass;BlockingCollection:I think, your choice is
BlockingCollection(if you really have many readers and writers).