How to find a scheduled job on displayname?


#1

I have written the following code but what bothers me is that I have to use an index 1 for Args[1].

Doesn’t exist for this a named parameter? Or can I implement this in another way?

string jobName = $“My friendly unique job name”;
var scheduledJob = hangfireMonitor.ScheduledJobs(0, int.MaxValue).SingleOrDefault(o => o.Value.Job.Args[1].ToString() == jobName);
if (scheduledJob.Key != null)
{
BackgroundJob.Delete(scheduledJob.Key);
}