I'm using WebClient
to download images over my code is very large, so I'm trying to separate my code into classes. Can someone give me an example of how to put the code below in a class or function?
WebClient client = new WebClient ();
client.DownloadDataCompleted +=
(object sender, DownloadDataCompletedEventArgs e) =>
{
byte[] result = e.Result;
if (result != null)
{
NSData data1 = NSData.FromArray (e.Result);
UIImage img = UIImage.LoadFromData (data1);
InvokeOnMainThread (delegate {
avatar.Image = img;
});
}
};
client.DownloadDataAsync(new Uri(
"http://xx.xx.xx.xx/fbcache/" +
list[indexPath.Row].comentario_id_usuario +
".jpg"));