不到一分钟的Hangfire重复执行任务

编程入门 行业动态 更新时间:2024-10-11 01:14:33
本文介绍了不到一分钟的Hangfire重复执行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有一种方法可以每隔几秒钟设置一次hangfire周期性作业? 我不寻求解决方案,即一劳永逸"任务会产生另一个一劳永逸"任务,如果没有,建议的替代方法是什么?

Is there a way to set hangfire recurring jobs every few seconds? I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives?

推荐答案

不确定何时支持该功能,但已在带有Hangfire 1.7.0的ASP.NET Core 2.0中进行了尝试.以下代码每20秒调度一次作业:

Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds:

RecurringJob.AddOrUpdate<SomeJob>( x => x.DoWork(), "*/20 * * * * *");

如果我没记错的话,由于Hangfire使用 NCrontab 允许cron表达式具有6个标记(第二个粒度而不是分钟的粒度).

If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to Hangfire use of NCrontab which allows cron expressions with 6 tokens (second granularity instead of minute granularity).

Hangfire仪表板还很好地显示了运行之间的较小时间间隔:

Hangfire dashboard also nicely shows the small time interval between runs:

更多推荐

不到一分钟的Hangfire重复执行任务

本文发布于:2023-11-27 15:28:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Hangfire

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!