Closed erossini closed 3 years ago
You should take that parameter to the method which you want to execute. In your case it is the Start method. HangFire simply inject that method.
And your code should be like:
var jobId = BackgroundJob.Enqueue(() => _process.Start(User.Identity.Name, filename, null));
And your Start method would be like:
public async Task Start(string username, string filename, PerformContext context)
{
_log.LogDebug($"User {username} started the import for {filename}");
}
Thank you so much!
Hi, I found this code and it is what I'm looking for but I don't know how to use in my code.
I start a process with
and then I have a generic class to run the process
How can I write a log in Hangfire? Where is
PerformContext
injected?