Threading and iterating through changing collections
Posted
by adamjellyit
on Stack Overflow
See other posts from Stack Overflow
or by adamjellyit
Published on 2010-06-10T05:30:50Z
Indexed on
2010/06/10
5:42 UTC
Read the original article
Hit count: 171
In C# (console app) I want to hold a collection of objects. All objects are of same type. I want to iterate through the collection calling a method on each object. And then repeat the process continuously. However during iteration objects can be added or removed from the list. (The objects themselves will not be destroyed .. just removed from the list). Not sure what would happen with a foreach loop .. or other similar method. This has to have been done 1000 times before .. can you recommend a solid approach?
© Stack Overflow or respective owner