Search code examples
c#jobshangfire

Use Hangfire job id in the code


I'm doing a Fire-and-Forget method invocation like this.

BackgroundJob.Enqueue(() => SendEmail(name));

I would like to pass the job id to the SendEmail() method and use it inside the method.


Solution

  • The easy way is to add

    PerformContext

    to the job method:. Hangfire Forum topic Use Hangfire job id in the code.