简体   繁体   中英

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?

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, eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM