Hangfire Discussion

How to check if BackgroundJob was created by RecurringJob, not launched from eg. Dashboard?

recurring
Tags: #<Tag:0x00007f85072e0570>

#1

Hello
While within method public void Execute(PerformContext context), I would like to get data from storage associated with RecuringJob:
var jsonContextArguments = context.GetJobData();

Howewer if BackgroundJob I’m in was not created by RecuringJob, context.GetJobData() throws generic Exception (https://github.com/icsharp/Hangfire.RecurringJobExtensions/blob/master/src/Hangfire.RecurringJobExtensions/RecurringJobInfoStorage.cs#L63).

Is there a way to find if BackgroundJob was created by RecurringJob, other than depending on UGLY comparison of thrown exception message?

Similar unanswered question here: Getting the RecurringJobId from a JobId in FilterAttribute


Getting the RecurringJobId from a JobId in FilterAttribute