title: Setting timeout on c# httpclient not working
body: <p>I set timeout to 1 millisecond, but when I test, all the http calls seem to work fine, almost like it's ignoring the timeout. How do I get it to work?</p>
  
  <p>Thanks</p>
  
  <pre><code>    private static HttpClient client = new HttpClient()
      {
          Timeout = TimeSpan.FromMilliseconds(1)
      }; // re-use the object
  
      /// &lt;summary&gt;
      /// Make a GET call.
      /// &lt;/summary&gt;
      public static async Task&lt;string&gt; GetAsync(string uri, string token_type, string access_token, string accept, string content_type)
      {
          HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
          if (content_type != null) request.Headers.TryAddWithoutValidation("Content-Type", content_type);
          if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); // ACCEPT header
          if (token_type != null &amp;&amp; access_token != null) request.Headers.Authorization = new AuthenticationHeaderValue(token_type, access_token);
          HttpResponseMessage g = await client.SendAsync(request);
  
          if (g.IsSuccessStatusCode)
          {
              return await g.Content.ReadAsStringAsync();
          }
          else
          {
              throw new ExternalException(await g.Content.ReadAsStringAsync(), (int)g.StatusCode);
              //throw new ExternalException(await g.Content.ReadAsStringAsync() + "      Reason: " + g.ReasonPhrase + "      Message: " + g.RequestMessage + "      Status Code: " + g.StatusCode + "      Token Type: " + token_type + "      Content Type: " + content_type + "      Accept: " + accept, (int)g.StatusCode);
          }
      }
  
      /// &lt;summary&gt;
      /// Make a POST call. The content type should be embedded in the postData already.
      /// &lt;/summary&gt;
      public static async Task&lt;string&gt; PostAsync(string uri, string token_type, string access_token, HttpContent postData, string accept)
      {
          string mes = await postData.ReadAsStringAsync();
          HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri)
          {
              Content = postData // CONTENT-TYPE header
          };
  
          if (accept != null) request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(accept)); // ACCEPT header
          if (token_type != null &amp;&amp; access_token != null) request.Headers.Authorization = new AuthenticationHeaderValue(token_type, access_token);
          HttpResponseMessage g = await client.SendAsync(request);
  
          if (g.IsSuccessStatusCode)
          {
              return await g.Content.ReadAsStringAsync();
          }
          else
          {
              throw new ExternalException(await g.Content.ReadAsStringAsync(), (int)g.StatusCode);
              //throw new ExternalException(await g.Content.ReadAsStringAsync() + "      Reason: " + g.ReasonPhrase + "      Message: " + g.RequestMessage + "      Status Code: " + g.StatusCode + "      Token Type: " + token_type + "      Post Data: " + mes + "      Accept: " + accept, (int)g.StatusCode);
          }
      }
  </code></pre>