Created
May 7, 2025 13:25
-
-
Save AaronSadlerUK/3fd3205359b795cc7916a69f436e11b3 to your computer and use it in GitHub Desktop.
How to detect a manual hangfire trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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