Can a HangFire background job start an external process? For instance if I write a console app to process some data in my database, and I call it using a hangfire background task is that a use case that works?
If I schedule my job like this,
BackgroundJob.Schedule<AssetValuation>(x => x.StartAssetValuation("petermc", "password", "AT", "Signs"), TimeSpan.FromSeconds(10));
And the code to run the job looks like this,
public void StartAssetValuation(string username, string password, string database, string assetType)
{
ProcessStartInfo pInfo = new ProcessStartInfo("calc");
Process mProcess = new Process();
mProcess.StartInfo = pInfo;
mProcess.Start();
mProcess.WaitForExit();
}
It all seems OK, but the WaitForExit doesn’t seem to wait. When I look in the dashboard the job is started and finished straight away instead of waiting for me to close the calc app.
If I run the code above in a console app it does wait.
I am hoping that running calc is the issue, and would like some confirmation that this is going to work when I write something proper in a console app.