I'm using Winforms and I've used a backgroundworker with producer/consumer objects inside. Inside DoWork, I have an object, let's call it Something that has:
Task.Run(() => producer.Produce(_appConfig.ScanPaths));
Task.Run(() => consumer.Consume());
When the consumer encounters an exception, it's not thrown and I can't handle it inside BackgroundWorkerRunWorkerCompleted. I have a
if (e.Error != null || e.Cancelled)
{
...
}
To handle it. Do you guys have any suggestions on how I can cancel the Backgroundworker and pop up an error MessageBox? Or a much better approach on what I'm doing with my producer/consumer tasks? I'd appreciate it. Thanks in advance!