Limitations of scheduled tasks (or how is constancy of tasks performed)?

I started reading the Hangfire documentation and found nothing about the limitations of the tasks.

As indicated, tasks (or tasks) are stored somewhere.

Since they are just delegates, the only thing that can be saved, as I understand it, is the delegate "body" (IL?). But there may be closures that provide some context for the task, for example, some external services that may require loading additional assemblies to run their code, etc.

How does Hangfire handle this?
Can a task contain any instructions in its body or any restrictions?

+7
c # hangfire
source share
2 answers

When you create a job, it calls Job.FromExpression , if you pass it anything other than a method invocation expression, it throws an exception. So, the only thing you can pass to BackgroundJob.Enqueue is the only line in which this line calls the function.

Then it serializes their object type and all passed in parameters to JSON using JobHelper.ToJson . When you pass an instance of a class, the instance is not serialized, but only the type, if the execution crosses the boundaries of the process, it will lose its internal state.

You might want to read the blog article on the old hangfire blog blog, " Are your methods ready to run in the background? "

+1
source share

It seems that the mechanism is based on Expression for planning operations, and the library is intended for "internal" (in the process) execution, mainly on ASP.Net sites.

Meaning, all the assemblies needed to carry out the scheduled operation should already be loaded into the web application memory space because they were necessary for scheduling the task (the application would not have been compiled if there hadn't been a Type from the assembly that was not referenced) .

Hope this makes it a little clearer!

0
source share

All Articles