Fetch image from the given URL using async

Below code snippet allows you to fetch image from the given URL using async and set it on XAML image control.
 
var httpClient = new HttpClient();
Stream st = await client.GetStreamAsync(URL);
var memoryStream =  new MemoryStream();
await st.CopyToAsync(memoryStream);
memoryStream.Position = 0;
BitmapImage bitmap = new BitmapImage(); 
bitmap.SetSource(memoryStream.AsRandonAccessStream());
imageControl.Source = bitmap; 
 
 
Ebook Download
View all
Learn
View all