Commits

alexdavies74  committed 16db66b

Make a manual asynchronous implementation

  • Participants
  • Parent commits 9e01f8b
  • Branches manual

Comments (0)

Files changed (1)

File FaviconBrowser/MainWindow.xaml.cs

-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Net;
 using System.Windows;
         private void AddAFavicon(string domain)
         {
             WebClient webClient = new WebClient();
-            byte[] bytes = webClient.DownloadData("http://" + domain + "/favicon.ico");
-            Image imageControl = MakeImageControl(bytes);
+            webClient.DownloadDataCompleted += OnWebClientOnDownloadDataCompleted;
+            webClient.DownloadDataAsync(new Uri("http://" + domain + "/favicon.ico"));
+        }
+
+        private void OnWebClientOnDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs args)
+        {
+            Image imageControl = MakeImageControl(args.Result);
             m_WrapPanel.Children.Add(imageControl);
         }