计划任务限制(或如何实现任务持久性)? [英] Scheduled tasks limitations (or how tasks persistence is implemented)?

查看:92
本文介绍了计划任务限制(或如何实现任务持久性)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始阅读Hangfire文档,但对任务限制一无所获.

I've started to read Hangfire documentation, and found nothing about task limitations.

如所声明的,任务(或作业)存储在某处.

As declared, tasks (or jobs) are stored somewhere.

由于它们只是委托,据我所知,唯一可以存储的是委托"body"(IL?).但是可能存在闭包,为任务提供了一些上下文,例如某些外部服务,可能需要加载额外的程序集以运行其代码等.

Since they are just delegates, the only thing could be stored, as far as I understand, is a delegate "body" (IL?). But there could be closures, that provides some context for the task, e.g., some external services, that can require to load extra assemblies to run their code, etc.

Hangfire如何处理此问题?
任务的主体中可以包含任何指令吗,还是有限制?

How Hangfire deals with this?
Can task contain any instructions in its body, or there are any limitations?

推荐答案

创建作业时,它会调用

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

然后使用

It then serializes they type of the object and all passed in parameters in to JSON using JobHelper.ToJson. When you pass in a instance of a class the instance is not serialized, only the type is, if the execution crosses process boundaries it will loose internal state.

您可能想阅读旧版hangfire博客网站上的博客文章"

You may want to read up on the blog article on the old hangfire blog site "Are your methods ready to run in background?"

这篇关于计划任务限制(或如何实现任务持久性)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆