From this post:
How do I get the current attempt number on a background job in Hangfire?
It is possible to get the retry count by using the magic string "RetryCount".
public void SendEmail(PerformContext context, string emailAddress)
{
string jobId = context.BackgroundJob.Id;
int retryCount = context.GetJobParameter<int>("RetryCount");
// send an email
}
How about if I need to get the total retry number? Can I use something like:
int retries = context.GetJobParameter<int>("Retries");
Or how can I get that info from the "PerformContext" (if possible at all)?
I need the total retries defined thus I can perform some tasks on the last retry.