private void EndWork(object sender, RunWorkerCompletedEventArgs e) { btnStop.Enabled = false; btnStart.Enabled = true; _packageTool = null; _worker = null; if (_closePending) { Close(); } _closePending = false; }
private void StartWork() { _worker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; _worker.DoWork += new DoWorkEventHandler(DoWork); _worker.ProgressChanged += new ProgressChangedEventHandler(Progress); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(EndWork); _packageTool = new PackageTool(); _packageTool.StopRequested = () => _worker.CancellationPending; _packageTool.Progress = (x) => _worker.ReportProgress(0, x); _worker.RunWorkerAsync(); }