private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { DecomposeResults results = e.Result as DecomposeResults; if (results.filePathsTiff.Count == 0) { customProgressBar1.Visible = false; } if (results.notCancelled) { label_status.Text = localization.GetValueForItem(LocalizedItem.TextDecomposeCompleted).Replace("%i", results.filePathsTiff.Count.ToString()); } else { label_status.Text = localization.GetValueForItem(LocalizedItem.TextDecomposeCompletedPartial); } // delete temporary files foreach (String file in results.filePathsPdf) { File.Delete(file); } label_status.ForeColor = Color.Green; button_decompose.Enabled = true; button_decompose.Text = localization.GetValueForItem(LocalizedItem.ButtonDecompose); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { DecomposeData argumentDecompose = e.Argument as DecomposeData; List <String> listFileNames = new List <string>(); DecomposeResults decomposeResults = new DecomposeResults(); decomposeResults.notCancelled = true; decomposeResults.filePathsPdf = argumentDecompose.filePathsPdf; int filesCount = argumentDecompose.filePathsPdf.Count; for (int i = 0; i < filesCount; i++) { if (backgroundWorker1.CancellationPending == true) { decomposeResults.notCancelled = false; break; } else { String fileName = argumentDecompose.filePathsPdf[i]; String fileNameTiff = fileName + ".tiff"; // create tiff ConvertPDFToTIFF(fileName, textBox_destFolder.Text, fileNameTiff); listFileNames.Add(fileNameTiff); backgroundWorker1.ReportProgress((i + 1) * 100 / filesCount); } } decomposeResults.filePathsTiff = listFileNames; e.Result = decomposeResults; }