3
Answers

Thread-safe Enumerator without Deadlock

Matthew Southall

Matthew Southall

14y
3.2k
1

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)