private void bgrwExport_Run(string type, DirectoryInfo folder) { if (!bgrwExport.IsBusy) { onProcessDescriptionChanged?.Invoke("Export started..."); onProgressInit?.Invoke(0, folder.GetDirectories().Count()); ArgForBgrwExport arg = new ArgForBgrwExport(); arg.type = type; arg.folder = folder; bgrwExport.RunWorkerAsync(arg); } }
private void bgrwExport_DoWork(object sender, DoWorkEventArgs e) { ArgForBgrwExport argForBgrwExport = (ArgForBgrwExport)e.Argument; BackgroundWorker worker = sender as BackgroundWorker; ExportManager = new ExportManager(argForBgrwExport.folder); string type = argForBgrwExport.type; if (type == "bitmap") { ExportManager.doBitmapExporting(worker); } if (type == "video") { ExportManager.doVideoExporting(worker); } if (worker.CancellationPending) { e.Cancel = true; } }