title: DelegatingHandler and HttpClient in a loop
body: <p>I am trying to execute <code>HttpClient.GetAsync</code> in a loop.<br>
  As per <a href="https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client#create-and-initialize-httpclient" rel="nofollow noreferrer">Microsoft Doc</a>, it is recommended to use 1 instance of <code>HttpClient</code>.  </p>
  
  <p>The way I'm getting <code>HttpClient</code> is  </p>
  
  <pre><code>var httpClient = HttpClientFactory.Create(HttpClientRequestHandler.HttpMessageHandler, delegatingHandler);
  </code></pre>
  
  <p>It hits <code>GetAsync</code> function fine, the first time, but when I reuse the <code>httpClient</code> reference, I'm getting the error: <code>The 'DelegatingHandler' list is invalid because the property 'InnerHandler' of 'HttpClientTelemetryHandler' is not null.</code></p>
  
  <p>When I tried creating a new <code>Handler</code> and <code>HttpClient</code> instance in the loop everytime, it works fine.</p>
  
  <p>This is now a conflict of interest. Should I create a new instance everytime in the loop, or is there any other way of doing this which is the right way to do it.  </p>
  
  <p><em>Additional info: The custom library which I consume to create the <code>HttpClient</code> is <code>.Net Standard 2.0</code> and the client application which calls the HttpClient is <code>.Net Core 2.1</code>.</em></p>
  
  <p>Appreciate any help.  </p>
  
  <p>Thanks.</p>