title: HttpClient.GetStringAsync() call freezes everything without throwing an error, but only under specific conditions
body: <p>I'm writing a Windows Universal app that relies heavily on information from a REST service.  To facilitate this (and provide caching support), I'm writing an accompanying library that the app will call into.  At the core of the code is the following function:</p>
  
  <p><strong>PokeLib.Utilities:</strong></p>
  
  <pre><code>    private static HttpClient fetcher = new HttpClient();
  
      public static async Task&lt;JObject&gt; GetPokemon(int n)
      {
          return await GetData(prefix + "pokemon/" + n + "/");
      }
  
      public static async Task&lt;JObject&gt; GetType(int n)
      {
          return await GetData(prefix + "type/" + n + "/");
      }
  
      private static Dictionary&lt;string, JObject&gt; resourceCache = new Dictionary&lt;string, JObject&gt;(); // TODO: Stale check
  
      public static async Task&lt;JObject&gt; GetData(string resourcePath, bool forceRefresh = false)
      {
          if (!resourceCache.ContainsKey(resourcePath) || forceRefresh)
              resourceCache[resourcePath] = await FetchDataFromServer(resourcePath);
  
          return resourceCache[resourcePath];
      }
  
      public static async Task&lt;JObject&gt; FetchDataFromServer(string resourcePath)
      {
          try
          {
              string json = await fetcher.GetStringAsync(baseUri + resourcePath); // ***** this is the line that dies *****
              return JObject.Parse(json);
          }
          catch (Exception e)
          {
              Debug.WriteLine(e.ToString());
              return null;
          }
      }
  </code></pre>
  
  <p>My code freezes at the labeled line under certain conditions, but I can't figure out what the issue is.  Note: typically, only GetPokemon() and GetItem() are called, but everything's public in the code for my debugging purposes.</p>
  
  <p>Works:</p>
  
  <ul>
  <li>any calls to GetPokemon(), from the app's code-behind or from elsewhere within the library</li>
  <li>calls to GetType(), but only from the app's code-behind (GetDataButton_Click)</li>
  </ul>
  
  <p>Not working:</p>
  
  <ul>
  <li>Calls to GetType() from elsewhere within the library, even though the path is virtually identical to that of GetPokemon()</li>
  </ul>
  
  <p>The catch block for the GetStringAsync call is <em>never</em> triggered, and I've confirmed through the debugger that the URI I'm passing it is correct.  The full library code is on <a href="https://github.com/Benjin/PokeLib" rel="nofollow">my Github</a>.  It's also worth noting that <em>all</em> of these work correctly from the Test project within the library's same solution.</p>
  
  <p><strong>Calling code:</strong></p>
  
  <p><strong>Type.cs:</strong></p>
  
  <pre><code>    public Type(int id, bool constructNow = false)
      {
          this.id = id;
  
          try
          {
              if (constructNow) // this is being called with true
                  Create().Wait();
          }
          catch (Exception e)
          {
              throw e;
          }
      }
  
      public override async Task Create()
      {
          JObject data = await Utilities.GetType(id);
  
          if (data == null)
              throw new KeyNotFoundException("Type ID #" + id + " does not exist");
  
          name = (string)data["name"];
          id = (int)data["id"];
          resourcePath = (string)data["resource_uri"];
      }
  </code></pre>
  
  <p>The calling Type.cs code is virtually identical to that of Pokemon.cs (including the .Wait()), so I don't think that would be the issue.</p>
  
  <p>Any help/ideas?  Thanks!</p>