internal int GetMemberCountImmediate(IConfigurationSession session) { int num = 0; try { if (!this.cachedCountLock.TryEnterReadLock(SystemAddressListMemberCountCacheValue.readerLockTimeout)) { throw new TransientException(DirectoryStrings.ErrorTimeoutReadingSystemAddressListMemberCount); } if (!this.systemAddressListExists) { throw new ADNoSuchObjectException(DirectoryStrings.SystemAddressListDoesNotExist); } num = AddressBookBase.GetAddressListSize(session, this.systemAddressListGuid); if (num == -1) { throw new ADNoSuchObjectException(DirectoryStrings.SystemAddressListDoesNotExist); } } finally { try { this.cachedCountLock.ExitReadLock(); } catch (SynchronizationLockException) { } } return(num); }
private void UpdateMemberCount(object o) { try { SystemAddressListMemberCountCacheValue.UpdateInfo updateInfo = (SystemAddressListMemberCountCacheValue.UpdateInfo)o; Exception ex = null; int num = 0; try { num = AddressBookBase.GetAddressListSize(updateInfo.Session, this.systemAddressListGuid); } catch (Exception ex2) { ex = ex2; } try { this.cachedCountLock.EnterWriteLock(); if (ex != null) { this.asyncException = ex; } else if (num == -1) { this.systemAddressListExists = false; this.memberCount = 0; this.lastQueriedTime = updateInfo.Now; this.lifetime = TimeSpan.MaxValue; } else { this.memberCount = num; this.lastQueriedTime = updateInfo.Now; this.lifetime = this.CalculateValidLifetime(updateInfo.Quota); } } finally { try { this.cachedCountLock.ExitWriteLock(); } catch (SynchronizationLockException) { } } } finally { Interlocked.Decrement(ref this.asyncUpdatesInProgress); } }