I am not too sure, so i thought i'd ask. Would removing and adding items to a System.Collections.Generic.List<>
object be non-thread safe?
My situation:
When a connection is received, it is added to the list, but also at the same time, there's a worker that's removing dead connections and such.
Is there a problem? Will a lock
do?
I also want to know if i'm allowed to use a lock on the list object with it's Foreach<>
method.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…