public ActiveHandlerTrackingEntry(
            int key,
            LifetimeTrackingHttpMessageHandler handler,
            TimeSpan lifetime)
        {
            Key      = key;
            Handler  = handler;
            Lifetime = lifetime;

            _lock = new object();
        }
示例#2
0
        private ActiveHandlerTrackingEntry CreateHandlerEntry(int key, RequestData requestData)
        {
            // Wrap the handler so we can ensure the inner handler outlives the outer handler.
            var handler = new LifetimeTrackingHttpMessageHandler(_createHttpClientHandler(requestData));

            // 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(key, handler, requestData.DnsRefreshTimeout));
        }