Hangfire store 回调是怎么实现的?
How does Hangfire store call backs?
鉴于此代码...
RecurringJob.AddOrUpdate(
() => Console.WriteLine("Recurring!"),
Cron.Daily);
Hangfire 如何存储每天调用的代码,以便将来可以 运行 调用?
简短的回答是反射和序列化,但 hangfire 有一个 Github 存储库,我认为最相关的代码片段可以在这里找到。
https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.Core/Common/Job.cs
代码注释
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.
鉴于此代码...
RecurringJob.AddOrUpdate(
() => Console.WriteLine("Recurring!"),
Cron.Daily);
Hangfire 如何存储每天调用的代码,以便将来可以 运行 调用?
简短的回答是反射和序列化,但 hangfire 有一个 Github 存储库,我认为最相关的代码片段可以在这里找到。 https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.Core/Common/Job.cs
代码注释
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.