public void Download( SplitDownloader.ProgressCb progressCb, SplitDownloader.CompletedCb completedCb, SplitDownloader.ExceptionCb exceptionCb) { this.Download(progressCb, completedCb, exceptionCb, (SplitDownloader.FileSizeCb)null); }
public void Download( SplitDownloader.ProgressCb progressCb, SplitDownloader.CompletedCb completedCb, SplitDownloader.ExceptionCb exceptionCb, SplitDownloader.FileSizeCb fileSizeCb) { this.m_ProgressCb = progressCb; this.m_CompletedCb = completedCb; this.m_ExceptionCb = exceptionCb; this.m_FileSizeCb = fileSizeCb; try { this.m_Manifest = this.GetManifest(); this.GetManifestFilePath(); if (this.m_FileSizeCb != null) { this.m_FileSizeCb(this.m_Manifest.FileSize); } this.StartWorkers(); this.m_ProgressCb(this.m_Manifest.PercentDownloaded()); for (int index = 0; (long)index < this.m_Manifest.Count; ++index) { SerialWorkQueue.Work work = this.MakeWork(this.m_Manifest[index]); this.m_Workers[index % this.m_NrWorkers].Enqueue(work); } this.StopAndWaitWorkers(); if (!this.m_Manifest.Check()) { throw new CheckFailedException(); } string filePath = this.m_Manifest.MakeFile(); this.m_Manifest.DeleteFileParts(); this.m_Manifest.DeleteManifest(); this.m_CompletedCb(filePath); } catch (Exception ex) { Logger.Error(ex.ToString()); this.m_ExceptionCb(ex); } finally { if (this.m_WorkersStarted) { this.StopAndWaitWorkers(); } } }