protected virtual void OnDownloadProgressChanged(long bytes) { Downloader.DownloadProgressChangedEventHandler downloadProgressChanged = this.DownloadProgressChanged; if (downloadProgressChanged == null) { return; } downloadProgressChanged(bytes); }
public bool DownLoadOem( Downloader.DownloadExceptionEventHandler downloadException, Downloader.DownloadProgressChangedEventHandler downloadProgressChanged, Downloader.DownloadFileCompletedEventHandler downloadFileCompleted, Downloader.FilePayloadInfoReceivedHandler filePayloadInfoReceived, Downloader.UnsupportedResumeEventHandler unsupportedResume, bool isRetry = false) { try { if (!string.IsNullOrEmpty(this.DownLoadUrl)) { Logger.Info("The new engine url is : " + this.DownLoadUrl); if (!isRetry) { this.DownloadPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(new Uri(this.DownLoadUrl).LocalPath)); } new Thread((ThreadStart)(() => { while (this.IsOemDownloadCancelling) { Thread.Sleep(1000); } if (!isRetry && System.IO.File.Exists(this.DownloadPath)) { Downloader.DownloadFileCompletedEventHandler completedEventHandler = downloadFileCompleted; if (completedEventHandler == null) { return; } completedEventHandler((object)null, (EventArgs)null); } else { this.MDownloader = new Downloader(); this.MDownloader.DownloadException += new Downloader.DownloadExceptionEventHandler(this.Downloader_DownloadException); this.MDownloader.DownloadException += downloadException; this.MDownloader.DownloadProgressChanged += downloadProgressChanged; this.MDownloader.DownloadFileCompleted += downloadFileCompleted; this.MDownloader.FilePayloadInfoReceived += filePayloadInfoReceived; this.MDownloader.UnsupportedResume += new Downloader.UnsupportedResumeEventHandler(this.Downloader_UnsupportedResume); this.MDownloader.UnsupportedResume += unsupportedResume; this.MDownloader.DownloadCancelled += new Downloader.DownloadCancelledEventHandler(this.Downloader_Cancelled); this.MDownloader.DownloadFile(this.DownLoadUrl, this.DownloadPath); } })).Start(); } } catch (Exception ex) { Logger.Error("Error while download file: {0}", (object)ex); return(false); } return(true); }