Simple: Don't start the BackgroundWorker twice.
You can check if it is already running by using the IsBusy
property, so just change this code:
worker.RunWorkerAsync();
to this:
if( !worker.IsBusy )
worker.RunWorkerAsync();
else
MessageBox.Show("Can't run the worker twice!");
Update:
If you do actually need to launch multiple background tasks at the same time, you can simply create multiple BackgroundWorker objects
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…