frmPrint printform = null; // New Class Variable private void btnPrint_Click(object sender, RoutedEventArgs e) { BackgroundWorker printthread = new BackgroundWorker(); printthread.DoWork += Print; printthread.ProgressChanged += PrintProgress; printthread.RunWorkerCompleted += PrintCompleted; printthread.WorkerReportsProgress = true; printthread.WorkerSupportsCancellation = true; printform = new frmPrint(printthread); // Create form printthread.RunWorkerAsync(); // Call DoWork() // Display form, if cancelled say so if (printform.ShowDialog() == false) { MessageBox.Show("Printing Aborted"); } }
frmPrint printform = null; // New Class Variable private void btnPrint_Click(object sender, RoutedEventArgs e) { BackgroundWorker printthread = new BackgroundWorker(); printthread.DoWork += Print; printthread.ProgressChanged += PrintProgress; printthread.RunWorkerCompleted += PrintCompleted; printthread.WorkerReportsProgress = true; printthread.WorkerSupportsCancellation = true; printform = new frmPrint(printthread); // Create form printthread.RunWorkerAsync(); // Call DoWork() // Display form, if cancelled say so if (printform.ShowDialog() == false) MessageBox.Show("Printing Aborted"); }