Thread-safe Enumerator without Deadlock

Oct 9 2010 5:45 PM

Hey, i need a way in C# to do a really long Enumeration without  Deadlocking the program, at the moment i have a List which it enumerates through doing GetEnumerator() on it and using While(e.MoveNext) etc. But it deadlocks i also have it locking the same list when it needs to add stuff to it.
How can i write a thread-safe enumerator without causing locking?

Answers (3)