Exemple #1
0
        public virtual void Poll(bool force = false, bool sync = false)
        {
            using (MiniProfiler.Current.Step("Poll - " + UniqueKey))
            {
                // Don't poll more than once every n seconds, that's just rude
                if (!force && DateTime.UtcNow < LastPoll.GetValueOrDefault().AddSeconds(MinSecondsBetweenPolls))
                {
                    return;
                }

                // If we're seeing a lot of poll failures in a row, back the hell off
                if (!force && PollFailsInaRow >= FailsBeforeBackoff && DateTime.UtcNow < LastPoll.GetValueOrDefault() + BackoffDuration)
                {
                    return;
                }

                // Prevent multiple poll threads for this node from running at once
                if (_isPolling)
                {
                    return;
                }
                _isPolling = true;

                if (sync)
                {
                    InnerPoll(force);
                }
                else
                {
                    _pollTask = Task.Factory.StartNew(() => InnerPoll(force));
                }
            }
        }
Exemple #2
0
        protected virtual void PollImpl(bool force, bool wait)
        {
            using (MiniProfiler.Current.Step("Poll - " + UniqueKey))
            {
                // Don't poll more than once every n seconds, that's just rude
                if (!force && DateTime.UtcNow < LastPoll.GetValueOrDefault().AddSeconds(MinSecondsBetweenPolls))
                {
                    return;
                }

                // If we're seeing a lot of poll failures in a row, back the hell off
                if (!force && PollFailsInaRow >= FailsBeforeBackoff && DateTime.UtcNow < LastPoll.GetValueOrDefault() + BackoffDuration)
                {
                    return;
                }

                // Prevent multiple poll threads for this node from running at once
                if (_isPolling)
                {
                    return;
                }
                _isPolling = true;

                PollStatus = "Poll Started";
                InnerPollImpl(force, wait);
                PollStatus = "Poll Complete";
            }
        }
Exemple #3
0
        public virtual void Poll()
        {
            // Don't poll more than once every n seconds, that's just rude
            if (DateTime.UtcNow < LastPoll.GetValueOrDefault().AddSeconds(MinSecondsBetweenPolls))
            {
                return;
            }

            // If we're seeing a lot of poll failures in a row... then wait
            if (PollFailsInaRow >= FailsBeforeBackoff && DateTime.UtcNow < LastPoll.GetValueOrDefault() + BackoffDuration)
            {
                return;
            }

            // Prevent multiple poll threads for this node from running at once
            if (isPolling)
            {
                return;
            }

            isPolling = true;
            pollTask  = Task.Factory.StartNew(() => InnerPoll());
        }