예제 #1
0
        public ActiveHandlerTrackingEntry(String name, LifetimeTrackingHttpMessageHandler handler, TimeSpan lifetime)
        {
            Name     = name;
            Handler  = handler;
            Lifetime = lifetime;

            _lock = new Object();
        }
예제 #2
0
        // Internal for tests
        internal ActiveHandlerTrackingEntry CreateHandlerEntry(String name)
        {
            // Wrap the handler so we can ensure the inner handler outlives the outer handler.
            var handler = new LifetimeTrackingHttpMessageHandler(InnerHandler);

            // Note that we can't start the timer here. That would introduce a very very subtle race condition
            // with very short expiry times. We need to wait until we've actually handed out the handler once
            // to start the timer.
            //
            // Otherwise it would be possible that we start the timer here, immediately expire it (very short
            // timer) and then dispose it without ever creating a client. That would be bad. It's unlikely
            // this would happen, but we want to be sure.
            return(new ActiveHandlerTrackingEntry(name, handler, HandlerLifetime));
        }