Ian Warburton
Ian Warburton

Reputation: 15676

How does Hangfire store call backs?

Given this code...

RecurringJob.AddOrUpdate(
    () => Console.WriteLine("Recurring!"),
    Cron.Daily);

How does Hangfire store the code to call daily such that it can run it in the future?

Upvotes: 2

Views: 61

Answers (1)

Robbert Draaisma
Robbert Draaisma

Reputation: 463

The short answer is reflection en serialization, but hangfire has a Github repository and I think the most relevant pieces of codes can be found here. https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.Core/Common/Job.cs

remark from the code

The ability to serialize an action is the cornerstone of marshalling it outside of a current process boundaries. We are leaving behind all the tricky features, e.g. serializing lambdas with their closures or so, and considering a simple method call information as a such an action, and using reflection to perform it.

Upvotes: 3

Related Questions