I have been testing out Hangfire and so far seems to do what we want, but I have come across an issue, but it may be the way we are using it. We have several tasks on our server that we want to transfer to being triggered from hangfire. Each of these tasks take a DTO which derives from a base class, BaseDTO.
When calling BackgroundJob.Enqueue , the DTO is passed as a parameter to the task to be run
e.g.
BackgroundJob.Enqueue(() => RunHangfireTaskImmediate(taskDTO);
....
[Queue("immediate")]
public void RunHangfireTaskImmediate(BaseDTO baseDTO)
{
//do stuff here
}
The issue is that when the task actually runs (i.e. in RunHangfireTaskImmediate), the data that is read back from storage (we use SQL) the only data that is deserialised is the BaseDTO, the rest is lost. Looking in the database the data looks to all be there in the Job.Arguments field.