Example #1
0
 private void downloader_DownloadError(object sender, DownloadErrorEventArgs e)
 {
     if (DownloadError != null)
     {
         DownloadError(sender, e);
     }
 }
Example #2
0
 /// <summary>
 /// 触发下载错误事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnDownloadError(DownloadErrorEventArgs e)
 {
     if (DownloadError != null)
     {
         DownloadError(this, e);
     }
 }
Example #3
0
 /// <summary>
 /// 异步下载方法
 /// </summary>
 /// <param name="asyncOp"></param>
 private void DownloadWorker(AsyncOperation asyncOp)
 {
     current = asyncOp;
     if (!TaskCanceled(asyncOp.UserSuppliedState))
     {
         try
         {
             webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
             webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
             foreach (var file in manifest.ManifestFiles.Files)
             {
                 string serverFileName = Path.Combine(manifest.ManifestFiles.BaseUrl, file.Source);
                 string clientFileName = Path.Combine(tempPath, file.Source);
                 Uri uri = new Uri(serverFileName);
                 if (!Directory.Exists(Path.GetDirectoryName(clientFileName)))
                 {
                     Directory.CreateDirectory(Path.GetDirectoryName(clientFileName));
                 }
                 while (webClient.IsBusy)
                 {
                     //阻塞异步下载
                 }
                 if (!cancel)
                 {
                     webClient.DownloadFileAsync(uri, clientFileName, file.Source);
                 }
             }
         }
         catch (Exception ex)
         {
             DownloadErrorEventArgs e = new DownloadErrorEventArgs();
             e.Error = ex;
             e.Manifest = manifest;
             OnDownloadError(e);
         }
     }
 }
Example #4
0
 void DownloadError(object sender, DownloadErrorEventArgs e)
 {
     Log.Write("下载过程中出现错误,错误描述:" + e.Error.Message + System.Environment.NewLine + "Version:" + e.Manifest.Version);
     MessageBox.Show("下载出错:" + e.Error.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }