I was wondering if anybody has any idea why the SynchronizedCollection<T> class was implemented in the ServiceModel assembly. I cannot see any connection between the assembly name and this (relatively) general purpose class.
I was wondering if anybody has any idea why the SynchronizedCollection<T> class was implemented
Share
This class is quite specific, and its name could even be misleading – its internal implementation does virtually nothing except for wrapping some operations (
Insert,Add,Clear,IndexOfetc.) inlock (this.sync) {}block, which doesn’t make it actually Synchronized (see concerns described in this article – in short, compound operations like LINQFirstOrDefaultare not thread-safe onSynchronizedCollection, as they do not acquire the lock).It is heavily used in
ServiceModelassembly itself, and probably was madepubliconly because someServiceModelclasses expose public properties of this type.So my guess is: it was put into
ServiceModelassembly because it doesn’t really belong to BCL and is just a DRYish BCL namespace extension for internalServiceModelneeds.