public ActiveHandlerTrackingEntry(
     string name,
     LifetimeTrackingHttpMessageHandler handler,
     TimeSpan lifetime)
 {
     Name     = name;
     Handler  = handler;
     Lifetime = lifetime;
     _lock    = new object();
 }
示例#2
0
        private ActiveHandlerTrackingEntry CreateHandlerEntry(HttpClientOptions options)
        {
            var builder = new DefaultHttpMessageHandlerBuilder(options.Proxy);

            foreach (var action in options.HttpMessageHandlerBuilderActions)
            {
                action(builder);
            }
            var handler = new LifetimeTrackingHttpMessageHandler(builder.Build());

            // 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(options.Name, handler, options.HandlerLifetime));
        }