Hello, I have a BackgroundJob like this
void process(int id) {
NotifyProcess(id, "Process started");
DoProcess1();
NotifyProcess(id, "20%");
DoProcess2();
NotifyProcess(id, "40%");
DoProcess3();
NotifyProcess(id, "60%");
DoProcess4();
NotifyProcess(id, "80%");
DoProcess5();
NotifyProcess(id, "Complete");
}
It is a very simple example of my notify process witch shows an incremental progress bar to the user, that works ok.
But, the problem is if maybe DoProcess4(), fails and throws an exception, in that case I would want to call:
NotifyProcess(id, "Error");
I easily could trap errors with try-catch an notify them, but the job is shown as Success on the Hangfire Dashboard, and that’s not what I want.
Any suggestion?
I think I have to do something with the logging interface, but how can I pass the notification id?
Thank you!!
BR