private void bgTransfer_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if (worker.CancellationPending == true) { e.Cancel = true; } else { client = new HFTClientWrapper(); if (client.ini(true, serverIp, serverPort, serverProgressPort, txtClientFileName.Text, txtServerFileName.Text, 0, "")) { bgTransfer.ReportProgress(100, client.run()); } else { bgTransfer.ReportProgress(100, -1); } } }