Skip to content

Instantly share code, notes, and snippets.

@AaronSadlerUK
Created May 7, 2025 13:25
Show Gist options
  • Save AaronSadlerUK/3fd3205359b795cc7916a69f436e11b3 to your computer and use it in GitHub Desktop.
Save AaronSadlerUK/3fd3205359b795cc7916a69f436e11b3 to your computer and use it in GitHub Desktop.
How to detect a manual hangfire trigger
bool isManual = false;
if (context != null)
{
var jobId = context.BackgroundJob?.Id;
if (jobId != null)
{
var jobDetails = JobStorage.Current.GetMonitoringApi().JobDetails(jobId);
if (jobDetails != null)
isManual = jobDetails.History.ToList()
.Any(x => x.Reason == "Triggered using recurring job manager");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment