Skip to content

Instantly share code, notes, and snippets.

@Melchy
Melchy / SkipWhenPreviousJobIsRunningAttribute.cs
Last active June 11, 2026 11:32 — forked from odinserj/SkipWhenPreviousJobIsRunningAttribute.cs
SkipWhenPreviousJobIsRunningAttribute.cs
using Hangfire.Client;
using Hangfire.Common;
using Hangfire.States;
using Hangfire.Storage;
namespace ContentAdmin.Worker.Infrastructure.Hangfire.JobScheduler.JobResolver;
// This is variation of https://gist.github.com/odinserj/a6ad7ba6686076c9b9b2e03fcf6bf74e
// which handles all edge cases (see comments on the gist)
public sealed class SkipWhenPreviousJobIsRunningAttribute : JobFilterAttribute, IClientFilter, IApplyStateFilter