Is it a good idea to send Exceptions as EventArgs in C#? (And not actually throw the Exception).
I have a class that performs a long running asynchronous task. If something goes wrong in the middle of the task, it will raise an Error event. Is it a good idea to add an Exception as part of the event arguments, or would it be better to use enums?
This class is just one of many that implement a certain interface. All classes in this interface raise the Error event when something goes wrong. Each class that implements this interface will run into different types of errors.
What are some of the best practices in a case such as this? Sending an Exception as an argument and not actually throwing it feels a bit wrong.
BackgroundWorker
class implements error handling in a similar way to what you suggest.