Why is SynchronizedCollection <T> in the System.ServiceModel assembly?

I was wondering if there is anyone why the SynchronizedCollection <T> class was implemented in the ServiceModel assembly. I do not see the connection between the assembly name and this (relatively) general purpose class.

+6
source share
1 answer

This class is quite specific, and its name can even be misleading - its internal implementation does practically nothing, except for wrapping some operations ( Insert , Add , Clear , IndexOf , etc. lock (this.sync) {} block lock (this.sync) {} , which doesn’t actually make it synchronized (see the problems described in this article - in short, complex operations such as LINQ FirstOrDefault are not thread- FirstOrDefault - FirstOrDefault on SynchronizedCollection , because they do not get the lock).

It is heavily used in the ServiceModel assembly itself and probably became public just because some ServiceModel classes provide public properties of this type.

Therefore, I assume: it was placed in the ServiceModel assembly because it actually does not belong to the BCL and is simply an extension of the DRYish BCL namespace for the internal needs of the ServiceModel .

+1
source

Source: https://habr.com/ru/post/890282/


All Articles