コード例 #1
0
        private void WriteNotification(bool asyncOperation)
        {
            ExTraceGlobals.NotificationsCallTracer.TraceDebug <SmtpAddress>((long)this.GetHashCode(), "Writing notifications for {0}.", this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress);
            bool flag = false;

            try
            {
                if (!this.notifiersStateLock.IsReaderLockHeld)
                {
                    this.notifiersStateLock.LockReaderElastic(5000);
                    flag = true;
                }
                TimeSpan value = new TimeSpan(DateTime.UtcNow.Ticks);
                double   num   = 0.0;
                if (this.startThrottleTime != null)
                {
                    num = value.Subtract(this.startThrottleTime.Value).TotalSeconds;
                }
                if (this.startThrottleTime == null || num > 10.0)
                {
                    this.startThrottleTime = new TimeSpan?(value);
                }
                foreach (KeyValuePair <IPendingRequestNotifier, PendingRequestManager.PendingNotifierState> keyValuePair in this.notifierDataAvailableState)
                {
                    IPendingRequestNotifier key = keyValuePair.Key;
                    PendingRequestManager.PendingNotifierState value2 = keyValuePair.Value;
                    int num2 = value2.CompareExchangeState(0, 1);
                    if (num2 != 1)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, int, int>((long)this.GetHashCode(), "PendingRequestManager.WriteNotification is skipping notifier {0} / {1} with state {2}.", key.GetType().Name, key.GetHashCode(), num2);
                    }
                    else
                    {
                        this.WriteNotification(asyncOperation, num, key, value2);
                    }
                }
                if (flag)
                {
                    this.notifiersStateLock.ReleaseReaderLock();
                    flag = false;
                }
            }
            finally
            {
                if (flag)
                {
                    this.notifiersStateLock.ReleaseReaderLock();
                }
            }
        }
コード例 #2
0
        internal void OnNotifierDataAvailable(object sender, EventArgs args)
        {
            bool flag = false;

            try
            {
                if (!this.notifiersStateLock.IsReaderLockHeld)
                {
                    this.notifiersStateLock.LockReaderElastic(5000);
                    flag = true;
                }
                if (sender == null)
                {
                    throw new ArgumentNullException("sender");
                }
                ExTraceGlobals.NotificationsCallTracer.TraceDebug <string, int>((long)this.GetHashCode(), "OnNotifierDataAvailable called by {0} / {1}", sender.GetType().Name, sender.GetHashCode());
                IPendingRequestNotifier key = (IPendingRequestNotifier)sender;
                PendingRequestManager.PendingNotifierState pendingNotifierState = null;
                if (!this.notifierDataAvailableState.TryGetValue(key, out pendingNotifierState))
                {
                    throw new ArgumentException("The sender object is not registered in the manager class");
                }
                int num = pendingNotifierState.CompareExchangeState(1, 0);
                if (num != 0)
                {
                    throw new OwaInvalidOperationException("OnNotifierDataAvailable should not be called if the manager did not consume the notifier's data yet. Notifier:" + sender.ToString());
                }
                this.WriteNotification(false);
            }
            catch (Exception e)
            {
                this.HandleException(sender.GetType().Name + ".Error", e);
            }
            finally
            {
                if (flag)
                {
                    this.notifiersStateLock.ReleaseReaderLock();
                }
            }
        }