It is extremely dangerous to modify a collection during its iteration; This is a recipe for crashes.
What would I do in your case is to use the queue, or perhaps to get involved a bit and implement the priority queue. A queue has the property that the last addition is the last to be serviced, just like a queue in a bank; you join the end of the line, and everyone in front of you is first served. So your loop will look something like this:
while(queue.Count > 0) { var currentCustomer = queue.Dequeue(); bool success = ServiceCustomer(currentCustomer); if (!success) {
A PriorityQueue works exactly like a queue, except that each task gets the priority associated with it. Tasks with a higher priority become VIPs and are queued before tasks with a lower priority. It's not too difficult to implement your own priority queue.
source share