I'm attempting to use HangFire to schedule any class that implements a certain interface I have called IScheduledService
. These services run as expected, but HangFire UI always shows the same name for each service in the HangFire dashboard PerformService()
. I know this is by design because I'm passing the same function name into each job, but users don't really know what specific job is running.
I created the interface with ServiceName
because I thought may be able to pass that into HangFire to override the visible job name instead of the name of the function being called, but don't see the ability to modify the job name. Is there a way to provide a custom job name so that the HangFire UI will show the title of each job based on the value of ServiceName
property?
public interface IScheduledService
{
string ServiceId { get; }
string ServiceName { get; }
void PerformService();
}
public class Service1 : IScheduledService
{
public string ServiceId { get => "e56643b1-f0cf-44b2-81ef-bf7a085de760"; }
public string ServiceName { get => this.GetType().Name; }
public void PerformService()
{
Console.WriteLine($"Hello world from {ServiceName}");
}
}