private void OnExtractionProgressCompleted(object sender, ProgressCompletedEventArgs e) { ExtractionTask task = e.State as ExtractionTask; if (task != null) { string status = "Extraction Complete"; if (e.ExceptionObject != null) { _errorMessages.Add(string.Format("Extraction Manager reporting the following error: {0} - {1}", task.Archive, ((Exception)e.ExceptionObject).Message)); _failedPatchFiles.Add(Path.GetFileName(task.Archive)); status = String.Format("Failed: {0}", ((Exception)e.ExceptionObject).Message); } Invoke((MethodInvoker) delegate() { ListViewItem item = _extractionTable[task]; UpdateExtractionStatus(task, item, e.Current, e.Max, e.ProgressPercentage, status); }); _extractionsComplete++; if (_extractionsComplete == _patches.Length) { InitializePatchingProcess(); } } }
private void UpdateExtractionStatus(ExtractionTask task, ListViewItem item, int current, int total, int completed, string status) { item.SubItems[0].Text = task.Archive; item.SubItems[1].Text = "100"; item.SubItems[2].Text = string.Format("{0}", current); item.SubItems[3].Text = string.Format("{0:00}%", completed); item.SubItems[4].Text = status; }
private void OnExtractionProgressUpdate(object sender, ProgressUpdateEventArgs e) { ExtractionTask task = e.State as ExtractionTask; if (task != null) { Invoke((MethodInvoker) delegate() { ListViewItem item = _extractionTable[task]; UpdateExtractionStatus(task, item, e.Current, e.Max, e.ProgressPercentage, "Extracting..."); }); } }
private void InitializeExtractionTask(DownloadTask state) { string filename = Path.GetFileName(state.Url); string archive = state.Destination; ListViewItem item = _downloadTable[state]; ExtractionTask task = new ExtractionTask(state.Destination, Path.GetDirectoryName(state.Destination)); task.ProgressUpdate += new EventHandler <ProgressUpdateEventArgs>(OnExtractionProgressUpdate); task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnExtractionProgressCompleted); Invoke((MethodInvoker) delegate() { UpdateExtractionStatus(task, item, 0, 100, 0, "Extraction Queued"); }); _extractionTable.Add(task, item); _extractionManager.Queue(task); if (!_extractionManager.HasBegun) { _extractionManager.Begin(); } }