Reputation: 5121
Using the following code my background worker RunWorkerCompleted
is never called and I can't figure out why.
void startWaitScan()
{
backgroundWorker1.RunWorkerAsync();
}
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
// do something here
}
void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Console.WriteLine("BackgroundWorker1_RunWorkerCompleted");
if (!stopAsync)
{
backgroundWorker1.RunWorkerAsync();
}
}
My goal is for the background worker to run continuously, I had this working in .NET but when I rewrote the code now in C# I'm having this issue.
Upvotes: 1
Views: 4581
Reputation: 1066
Do you have all the events hooked up correctly ??
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
backgroundWorker1_RunWorkerCompleted);
Upvotes: 9