コード例 #1
0
        private void ThrottleTimeout(object state)
        {
            ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "Throttle Timeout method was called - throttle timeout elapsed");
            IPendingRequestNotifier pendingRequestNotifier = state as IPendingRequestNotifier;
            bool flag = false;

            try
            {
                if (pendingRequestNotifier == null)
                {
                    throw new ArgumentException("State paramenter is invalid");
                }
                this.notifiersStateLock.LockReaderElastic(5000);
                flag = true;
                PendingRequestManager.PendingNotifierState pendingNotifierState = null;
                if (!this.notifierDataAvaiableState.TryGetValue(pendingRequestNotifier, out pendingNotifierState))
                {
                    throw new ArgumentException("The sender object is not registered in the manager class");
                }
                Interlocked.Exchange(ref pendingNotifierState.OnDataAvailableThrottleCount, 0);
                ExTraceGlobals.NotificationsCallTracer.TraceDebug <int>((long)this.GetHashCode(), "Notifier {0} is not on throttle period anymore", pendingRequestNotifier.GetHashCode());
                this.OnNotifierDataAvailable(pendingRequestNotifier, null);
            }
            catch (Exception e)
            {
                this.HandleException(e, false);
            }
            finally
            {
                if (flag)
                {
                    this.notifiersStateLock.ReleaseReaderLock();
                }
            }
        }
コード例 #2
0
        internal void OnNotifierDataAvailable(object sender, EventArgs args)
        {
            bool flag = false;

            try
            {
                this.notifiersStateLock.LockReaderElastic(5000);
                flag = true;
                if (sender == null)
                {
                    throw new ArgumentNullException("sender");
                }
                ExTraceGlobals.NotificationsCallTracer.TraceDebug <int>((long)this.GetHashCode(), "OnNotifierDataAvailable called by a notifier.Notifier:{0}", sender.GetHashCode());
                IPendingRequestNotifier key = (IPendingRequestNotifier)sender;
                PendingRequestManager.PendingNotifierState pendingNotifierState = null;
                if (!this.notifierDataAvaiableState.TryGetValue(key, out pendingNotifierState))
                {
                    throw new ArgumentException("The sender object is not registered in the manager class");
                }
                int num = Interlocked.CompareExchange(ref pendingNotifierState.State, 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());
                }
                if (this.lockTracker.TryAcquireLock())
                {
                    this.WriteNotification(false);
                }
            }
            catch (Exception e)
            {
                this.HandleException(e, false);
            }
            finally
            {
                if (flag)
                {
                    this.notifiersStateLock.ReleaseReaderLock();
                }
            }
        }