private void prepareObjects() { bgWorker = new BackgroundWorker(); bgWorker.WorkerSupportsCancellation = true; bgWorker.DoWork += backgroundWorker_DoWork; bgWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; progressWindow = new ProgressWindow(); progressWindow.Cancel += cancelWork; progressWindow.Show(); }