C#C
C#3y ago
Jason

Restart method with fresh list to iterate through without triggering 'collection was modified' error

I've provided a pseudo code version of the problem. This normally wouldn't be a problem as I could just remove the code that modifies the list, however I want this operation to work automatically without my input / manual intervention. What can I add to this code to make that happen? I considered adding cancellation tokens but that would only cancel the current task, it wouldn't take the program out of the current iteration (inside this try catch block).
screen.jpg
Was this page helpful?