I can't remember the reason because we have both. I think you can remove MethodImpl(MethodImplOptions.Synchronized) but NOT lock(SyncRoot). Note: that is not only a read, is has an Add.
2009/11/30 Steve Strong <[email protected]> > (another) quick question: In the various caches used for holding Query > Plans, there's lots of code like this: > > public object this[object key] > { > [MethodImpl(MethodImplOptions.Synchronized)] > get > { > lock (SyncRoot) > { > object result = > softReferenceCache[key]; > if (result != null) > { > > strongReferenceCache.Add(key, result); > } > return result; > } > } > } > > Is there any good reason for the two locks? Seems to me to just be > unnecessary overhead, but I'm perhaps missing something subtle... > > Cheers, > > Steve > > -- Fabio Maulo
