Example #1
0
        internal static UpgradeableReadLockScope Create(ReaderWriterLockSlim readerWriterLock)
        {
            if (readerWriterLock == null)
            {
                throw new ArgumentNullException("readerWriterLock");
            }
            UpgradeableReadLockScope upgradeableReadLockScope = new UpgradeableReadLockScope(readerWriterLock);

            upgradeableReadLockScope.Acquire();
            return(upgradeableReadLockScope);
        }
            private T GetCachedConfigData <T>(Func <T> getCachedDataFunc)
            {
                T result;

                using (UpgradeableReadLockScope upgradeableReadLockScope = UpgradeableReadLockScope.Create(this.readerWriterLock))
                {
                    if (this.IsDirty())
                    {
                        using (upgradeableReadLockScope.Upgrade())
                        {
                            this.configFileInfo.Refresh();
                            this.ReadConfigStream();
                            return(getCachedDataFunc());
                        }
                    }
                    using (upgradeableReadLockScope.Downgrade())
                    {
                        result = getCachedDataFunc();
                    }
                }
                return(result);
            }