Background method configure

I’m calling a background method with delay like this:

jobId = BackgroundJob.Schedule((x) => x.SendEmail(parameters), timespan);

The problem is that if the day it has to be executed is a weekend, it delays the execution of the work to Monday. Is this possible?

Please, how could I check if this behavior is configured like this?

Is there a way without resorting to recurring jobs, since it is a job that has to be executed only once, to configure the background method to run without skipping the weekend?

I’m not really following what the issue is. You’re specifying when it should run. You have not supplied how “timespan” is determined so it is difficult to provide any assistance.

I’m giving the time value in the timespan variable, for example.
Where timespan is equal to 4 days, 22 hours 35 minutes,…

When the deadline coincides with a weekend, the job is executed on Monday, 1 or 2 days late depending on whether it was originally scheduled for Saturday or Sunday.

I would like to know if there is a way to check the background method settings or if it is possible to make some additional settings so that this does not happen.

I’m still not understanding the issue. You haven’t really explained how the value gets to be almost 5 days. You are specifying the schedule, if it is occurring too late then schedule it sooner.

Are you saying that if it is scheduled for a Saturday or Sunday, Hangfire is not running it until Monday?

I think the time lapse is well calculated. For example:

TimeSpan timespan = (TimeSpan)(notificationDate - DateTime.Now);

notificationDate is the value of a parameter of type DateTime.

And then timespan is used to schedule the job.

BackgroundJob.Schedule((x) => x.SendEmail(parameters), timespan);

When the notificationDate value is a day on a weekend, the job is not done until Monday. But if it is any other day of the week everything happens correctly.

I guess it has nothing to do with hangfire. I can’t find anything that can configure this behavior. I guess it must be for another reason.

Thank you so much.