Anyway I have realised that this cannot work, but I have noted a weird behaviour that I am curious about.
When you do the above the job just keeps running over and over again until you force it to stop. The screenshot below is a partial screenshot. It started calc up 13 times before I could stop it. Why is that?
Please don’t enqueue Process.Start method calls, use a wrapper method, see the following code snippet for example.
public static void StartProcess(string fileName)
{
var process = Process.Start(fileName);
if (process == null)
{
throw new InvalidOperationException("No process resource is started (for example, if an existing process is reused).");
}
process.WaitForExit();
}
I will think how to move background jobs to the Failed state instead of re-running them again and again in cases like yours.
Thanks. We have since done what you suggested and put this in a wrapper method, and created our database fresh. I wasn’t expecting the job to keep repeating so I appreciate the explanation.
I have also found the logs now which I hadn’t previously which helps a lot.
Since version 1.5.0 (just released), Hangfire tries to serialize the result, and in case of an exception it simply writes “Can’t serialize the return value” message instead of the result. So serialization issues don’t lead to infinite processing loops now.