When I pushed the Transfer button a second time, I get the this error message, System.InvalidOperationException: 'This BackgroundWorker is currently busy and cannot run multiple tasks concurrently.' Can someone help me with this problem?
C#:
private void buttonTransfer_Click(object sender, EventArgs e)
{
if (backgroundWorker1.IsBusy)
{
backgroundWorker1.WorkerSupportsCancellation = true;
backgroundWorker1.CancelAsync();
MessageBox.Show("Running!");
}
richTextBoxViewStatus.Clear();
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
port.Close();
backgroundWorker1.WorkerSupportsCancellation = true;
backgroundWorker1.CancelAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
do some work
}