Retry attempts inside BackgroundJob

Hi,

There is any way to get the retry attempts (RetryCount) for a BackgroundJob inside the function that is called?

I tried to put “PerformContext context” in the functions parameters and then “context.GetJobParameter<int?>(“RetryCount”) ?? 0” but i always get 0, even if is the 5th retry.

There is any chance to get the retry count value?

Regards

I solve it by adding in the catch:
var retryCountHangfire = context?.GetJobParameter<int?>(“RetryCount”) ?? 0;
context.SetJobParameter(“RetryCount”, retryCountHangfire + 1);

Then in the try i read it.

context is PerformContext