private void DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; e.Result = this.method(this.repoCredentials, this.actualNode); if (worker.CancellationPending) e.Cancel = true; }