コード例 #1
0
            internal override void StartHandlerEntryTimer(ActiveHandlerTrackingEntry entry)
            {
                if (EnableExpiryTimer)
                {
                    lock (ActiveEntryState)
                    {
                        if (ActiveEntryState.ContainsKey(entry))
                        {
                            // Timer already started.
                            return;
                        }

                        // Rather than using the actual timer on the actual entry, let's fake it with async.
                        var completionSource = new TaskCompletionSource <ActiveHandlerTrackingEntry>();
                        var expiryTask       = completionSource.Task.ContinueWith(t =>
                        {
                            var e = t.Result;
                            ExpiryTimer_Tick(e);

                            lock (ActiveEntryState)
                            {
                                ActiveEntryState.Remove(e);
                            }
                        });

                        ActiveEntryState.Add(entry, (completionSource, expiryTask));
                    }
                }
            }
コード例 #2
0
        public ExpiredHandlerTrackingEntry(ActiveHandlerTrackingEntry other)
        {
            Name = other.Name;

            _livenessTracker = new WeakReference(other.Handler);
            InnerHandler     = other.Handler.InnerHandler;
        }
コード例 #3
0
        public HttpMessageHandler CreateHandler(string name)
        {
            ThrowHelper.ThrowIfNull(name);

            ActiveHandlerTrackingEntry entry = _activeHandlers.GetOrAdd(name, _entryFactory).Value;

            StartHandlerEntryTimer(entry);

            return(entry.Handler);
        }
コード例 #4
0
        public HttpMessageHandler CreateHandler(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            ActiveHandlerTrackingEntry entry = _activeHandlers.GetOrAdd(name, _entryFactory).Value;

            StartHandlerEntryTimer(entry);

            return(entry.Handler);
        }
コード例 #5
0
 // Internal so it can be overridden in tests
 internal virtual void StartHandlerEntryTimer(ActiveHandlerTrackingEntry entry)
 {
     entry.StartExpiryTimer(_expiryCallback);
 }