title: UIProgressView track status of download ios monotouch
body: <p>I have been looking all over to see how to update progressview while image downloads. My current download code is</p>
  
  <pre><code>ThreadPool.QueueUserWorkItem(new WaitCallback(RetrieveImage),(object)cell);
  
  private void RetrieveImage(object val)
  {
  CustomViewCell cell = (CustomViewCell)val;
  int i = 0;
  //lock(_imgDict){
  //if ( !_imgDict.ContainsKey(cell.imageUrl) )
  //{
       NSUrl nsUrl = new NSUrl(cell.imageUrl);
       NSData data = NSData.FromUrl(nsUrl);
       if (data != null) {
  InvokeOnMainThread (() =&gt; {
      cell.imgImageView.Image = new UIImage (data);
      i++;
      cell.ProgressBar.Progress = (float)(i + 1) / 3; 
      });
      //_imgDict.Add (cell.imageUrl, data);
  } 
  }
  </code></pre>
  
  <p>All this does is show the progress bar on top of the image with 75% complete. not really showing progress being updated? How do I use this current thread to update the progress bar while the image is still being downloaded. I seen other examples but not really able to follow them.</p>
  
  <p><strong>Edit:</strong></p>
  
  <pre><code>ThreadPool.QueueUserWorkItem(new WaitCallback(RetrieveImage),(object)cell); 
  
   ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
   using(var client = new WebClient())
   {
  client.DownloadProgressChanged+= 
   delegate(object sender, DownloadProgressChangedEventArgs e)
      {
           if (e.TotalBytesToReceive != 0) {
          InvokeOnMainThread (() =&gt; {
          cell.PG.Progress = e.BytesReceived / 
                  e.TotalBytesToReceive;
                });
               }
       };
  client.DownloadDataCompleted += 
  delegate(object sender, DownloadDataCompletedEventArgs e)
      {
        if(e.Result!=null)
            {
                  NSData data = NSData.FromArray(e.Result);
             _imgDict.Add (cell.ImageUrl, data);
           InvokeOnMainThread (() =&gt; {
                    cell.PG.Hidden=true;
                    cell.imgImageView.Image =  UIImage.LoadFromData(data);
              });
       }
      else
      {
          InvokeOnMainThread (() =&gt; {
          cell.PG.Hidden=true;
                      cell.imgImageView.Image = UIImage.FromBundle("Images/retrydownload.png");
                      });
      }
   }; 
      client.DownloadDataAsync(new Uri(cell.ImageUrl));
  }
  </code></pre>
  
  <p>now with this updated code I do not see the progress bar while download</p>