There are two issues with your code:
The single parameter constructor of SynchronizedReadOnlyCollection<T>
takes a syncRoot object
, not the underlying collection, take a look at the documentation around the constructors here.
Unlike other read-only collection wrappers, the SynchronizedReadOnlyCollection<T>
also takes a snapshot of the provided collection rather than keeping a reference to the underlying collection, this can be seen in the source code here.
Being perfectly honest, I can't imagine ever using SynchronizedReadOnlyCollection<T>
, if it maintained a reference to the underlying collection it could have some use, but as it takes a snapshot, it seems 100% useless to me, why lock around a resource which can only be read from? That and the fact it doesn't even implement IReadOnlyCollection<T>
, I wouldn't bother trying to use it.
There is perhaps a use-case when deriving from this type and using the Items
property to mutate the underlying collection, however I have seen no examples which do this.