private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { if (BGWorker.CancellationPending) { e.Cancel = true; } else { M3uData msg = e.Argument as M3uData; for (int i = 0; i < msg.listbox.CheckedItems.Count; i++) { if (!msg.mngr.Copy_File(msg.listbox.CheckedItems[i].ToString(), msg.folder)) { BGWorker.CancelAsync(); } int percentComplete = (int)((i + 1) * 100) / msg.listbox.CheckedItems.Count; BGWorker.ReportProgress(percentComplete); } } }
public Progress(M3uManager m, string f, CheckedListBox clb) { InitializeComponent(); msg = new M3uData(m, f, clb); }