Question

Maybe the question doesn't make sense, but the problem is that my program runs just fine for me. However, when I sent it to my brothers PC (relatively new one) to test it out, the BackgroundWorker is not firing.

BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(fetchList);
if (!bw.IsBusy)
{
    // I have checked that this stage is reached, and it is.
    bw.RunWorkerAsync();
}

I also debugged the function that is being called and it certainly is not firing. I am using .NET 2.0 so I don't assume this should be the issue?

If it matters, the function being called by the worker is using 2 packages; HtmlAgilityPack and Newtonsoft.Json

Was it helpful?

Solution

No, you can count on that code work just fine. What you can't count on is your fetchList method working properly. If it throws an exception for any reason then that will not stop your program to tell you about it. The exception is captured and passed as the e.Error property to the RunWorkerCompleted event handler. You need to check it and take appropriate corrective actions, at a minimum let the user know.

You don't have a RunWorkerCompleted event handler. So of course you can't know why fetchList doesn't work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top