I m using ConcurrentBag to store object in run time. At some point I need to empty the bag and store the bag content to a list. This is what i do:
I have a dictionary that is shared among number of threads. Every thread reads specific value from the dictionary according to a given key, but - if the key does not exist in the dictionary the thread
Recently I have been refactoring some of my C# code and I found a few double-checked locking practices taking place. I didn\'t know it was a bad practice back then and I really want to get rid of it.
We have project targeted .NET 2.0 RTM (yes, it should be .NET 2.0 RTM, we have some orthodox clients). And I\'m just wondering what are the downsides of ReaderWriterLock? Why is it so bad that everyon
I wrote a small piece of code that rapidly read and write to a dictionary from multiple threads. I used ReaderWriterLockSlim to protect the code and still received an exception for allegedly trying to
I like the shortcut in C# of 开发者_JAVA技巧lock(myLock){ /* do stuff */}. Is there an equivalent for read/write locks? (Specifically ReaderWriterLockSlim.) Right now, I use the following custom metho
I have some code which must be thread safe whose behavior resembles this: protected long m_RunningValue
I ha开发者_高级运维ve an example piece of code the illustrates issues in my code when GC.Collect is carried out on a class having a ReaderWriterLockSlim member variable. The GC.Collect takes between 2
I have an object which holds a collection of it开发者_运维知识库ems. I want to be able to add items to the collection through an AddItem method and also to go through all of the items in the collectio
So I have a situation where I may have many, many reads and only the occasional write to a resource shared between multiple threads.