title: Synchronously download an image from URL
body: <p>I just want to get a BitmapImage from a internet URL, but my function doesn't seem to work properly, it only return me a small part of the image. I know WebResponse is working async and that's certainly why I have this problem, but how can I do it synchronously?</p>
  
  <pre><code>    internal static BitmapImage GetImageFromUrl(string url)
      {
          Uri urlUri = new Uri(url);
          WebRequest webRequest = WebRequest.CreateDefault(urlUri);
          webRequest.ContentType = "image/jpeg";
          WebResponse webResponse = webRequest.GetResponse();
  
          BitmapImage image = new BitmapImage();
          image.BeginInit();
          image.StreamSource = webResponse.GetResponseStream();
          image.EndInit();
  
          return image;
      }
  </code></pre>