I am trying to get an overview of the thread safety theory behind the collections in C#.
Why are there no concurrent collections as there are in Java? (java docs). Some collections appear thread safe but it is not clear to me what the position is for example with regard to:
compound operations,
safety of using iterators,
write opera...
Is there a C# class that provides map with weak keys or/and weak values?
Or at least WeakHashMap like functionality.
...
My problem
Let's say I want to hold my messages in some sort of datastructure for longpolling application:
1. "dude"
2. "where"
3. "is"
4. "my"
5. "car"
Asking for messages from index[4,5] should return:
"my","car".
Next let's assume that after a while I would like to purge old messages because they aren't useful anymore and I want...
I have a grid which is defined as: List<List<Cell>>, where "Cell" is a custom class of mine.
My program has several threads which access various coordinates on the grid, and change data in the "Cell" class. But I only want one thread writing data to a "Cell" object at a time.
I thought using concurrent collections such as ConcurrentBag w...
Per the title - are there good built-in options in C#/.NET for fail-safe iteration over an IList or an IDictionary?
Where I'm running into problems is with code similar to the following:
IList<Foo> someList = new List<Foo>();
//...
foreach (Foo foo in someList) {
if (foo.Bar) {
someList.remove(foo);
}
}
which throws the fol...