如何安排作业在Hangfire中的特定日期执行 [英] How do I schedule a job to be run at a specific date in Hangfire

查看:110
本文介绍了如何安排作业在Hangfire中的特定日期执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hangfire.io支持对重复作业进行类似于CRON的调度.但是我如何指定特定的作业应该在特定的日期/时间运行一次,例如应该在2016年6月4日的16:22上运行作业-并且只能在该特定时间点进行?

Hangfire.io supports making a CRON-like scheduling of recurring jobs. But how do I specify, that a specific job should be run once, at a specific date/time, e.g. that a job should be run June 4th 2016, at 16:22 - and only at that specific point in time?

问相同问题的类似方法可能是:CRON表达式的子集描述了多大这里,由Hangfire支持吗?(所描述的CRON表达式支持可以使用的年份"字段.)

A similar way to ask the same question could be: how large a subset of the CRON expression described here, is supported by Hangfire? (The described CRON expression supports a "Year"-field which could be used).

此外,如果我使用Hangfire进行作业处理,那么您认为Hangfire首先是安排一次性批处理作业的最佳选择吗?

Also, do you think Hangfire is the best choice to schedule one-off batch jobs in the first place, provided that I use Hangfire for job processing?

推荐答案

您可以使用BackgroundJob.Schedule(Expression> methodCall,DateTimeOffsetdt)方法.

You can use BackgroundJob.Schedule(Expression> methodCall, DateTimeOffsetdt) method.

BackgroundJob.Schedule(methodCall, enqueueAt);

这篇关于如何安排作业在Hangfire中的特定日期执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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