I thought the point was that you *do* make the copy by enumerating. The idea is that you acquire the lock, build a copy as quickly as you can using the enumerator, release the lock, and then work through the copy at your leisure. I thought that was what the original post was suggesting. (Although since you wrote the original post, I guess you know what it meant better than I do. ;-) )
This has two benefits: (1) you don't acquire the lock for any longer than you need to, which is good because lock contention can be bad for scalability. (2) it's OK to modify the collection as you enumerate through it, because you won't be modifying your copy. Why would you actually want to make the copy by some means other than enumeration? (I originally assumed Graeme's post was a joke...) -- Ian Griffiths DevelopMentor ----- Original Message ----- From: "Duncan Godwin" <[EMAIL PROTECTED]> > Depending on what's in the collection you can either use a collections > Clone() method if you need a shallow copy, or Serialize via a MemoryStream > if you need a deep copy. > > ----- Original Message ----- > From: "Graeme Foster" <[EMAIL PROTECTED]> > > > The fun bit is making the copy *without enumerating* ;) > > > > -----Original Message----- > > From: Duncan Godwin > > > > The alternative is as mentioned in Effective Java, lock briefly, > > make a defensive copy of the collection, then enumerate. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.