I have c# app that has UI and background threads. Based on user input I like to stop and start the background thread. I have two options here as I see:
1) totally stop and then start background thread as new thread ( I have not been able to this. I keep getting my process ended message)
2) Pause the background thread until user click run again.
Here is the code that I call again after bw.CancelAsync();
private void StartBackgroundWorker()
{
bw = new BackgroundWorker();
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = true;
bw.DoWork += bw_DoWork;
bw.RunWorkerCompleted += bw_RunWorkerCompleted;
bw.RunWorkerAsync("Background Worker");
}
Thanks in advance for your help.