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.
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
, IndexOf
etc.) in lock (this.sync) {}
block, which doesn't make it actually Synchronized (see concerns described in this article - in short, compound operations like LINQ FirstOrDefault
are not thread-safe on SynchronizedCollection
, as they do not acquire the lock).
It is heavily used in ServiceModel
assembly itself, and probably was made public
only because some ServiceModel
classes expose public properties of this type.
So my guess is: it was put into ServiceModel
assembly because it doesn't really belong to BCL and is just a DRYish BCL namespace extension for internal ServiceModel
needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With