Exemple #1
0
 public object DownloadBytes(Uri uri, DownloadCompleteDelegate onComplete, object userData)
 {
     WebClient client = GetIdleClient();
     Handle handle = new Handle(uri, client, onComplete, null, userData);
     try
     {
         client.DownloadDataAsync(uri, handle);
     }
     catch (Exception)
     {
         client.CancelAsync();
         m_idleClients.Add(client);
         return null;
     }
     return handle;
 }
Exemple #2
0
 public object DownloadFile(Uri uri, string fileName, DownloadCompleteDelegate onComplete, ProgressChangedDelegate onProgressChanged, object userData)
 {
     WebClient client = GetIdleClient();
     Handle handle = new Handle(uri, client, onComplete, onProgressChanged, userData);
     try
     {
         FileInfo file = new FileInfo(fileName);
         if (file.Exists)
             file.Delete();
         if (!file.Directory.Exists)
             file.Directory.Create();
         client.DownloadFileAsync(uri, fileName, handle);
     }
     catch (Exception)
     {
         client.CancelAsync();
         m_idleClients.Add(client);
         return null;
     }
     return handle;
 }
Exemple #3
0
 public Handle(Uri uri, WebClient client, DownloadCompleteDelegate onComplete, ProgressChangedDelegate onProgressChanged, object userData)
 {
     this.startTime = DateTime.Now;
     this.uri = uri;
     this.client = client;
     this.onComplete = onComplete;
     this.onProgressChanged = onProgressChanged;
     this.complete = false;
     this.userData = userData;
 }