We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Use hangfire to execute an external command

Hi all!

Can anyone show an example on how to use hangfire to enqueue an external command?
Thank you in advance,

Alexandros

public class EmailService
{
    public void Send() { }
}

BackgroundJob.Enqueue<EmailService>(x => x.Send());

Within Send, it would call the external command.

I have tried using System.Diagnostics.Process.Start() either as:

var jobId = BackgroundJob.Enqueue(() => System.Diagnostics.Process.Start(startInfo));

or in a wrapper class. In both cases, I received error Newtonsoft.Json.JsonSerializationException: Can not find the target method.
It seems like hangfire cannot resolve this.