I know that you can handle BackgroundWorker errors in the RunWorkerCompleted handler, as in the following code
var worker = new BackgroundWorker();
worker.DoWork += (sender, e) =>
{
throw new InvalidOperationException("oh shiznit!");
};
worker.RunWorkerCompleted += (sender, e) =>
{
if(e.Error != null)
{
MessageBox.Show("There was an error! " + e.Error.ToString());
}
};
worker.RunWorkerAsync();
But my problem is that I am still receiving the message: the error was not addressable in the user code in the line
throw new InvalidOperationException("oh shiznit!");
How can I solve this problem?
source
share