惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
小众软件
小众软件
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
博客园_首页
G
Google Developers Blog

博客园 - 宁静致远.

Swagger 页面登录验证中间件(Basic认证) Hangfire 的 ASP.NET Core 应用程序始终运行在IIS上 DevExpress 无法打开WinForm设计窗体,报错: 类型 universe 无法解析程序集: System, Version=2.0.0.0 PowerDesigner参数设置 雪花漂移ID,Yitter.IdGenerator 封装成一个适用于 ASP.NET Core 6.0 的服务组件 解决 Hangfire 中使用HttpClient 任务超时问题 TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. ASP.NET Core API 自定义全局异常 Dapper模糊查询Like 删除重复记录,仅留一条 Task 多线程执行 使用Hangfire+.NET 6实现定时任务管理(推荐) 使用 IHttpClientFactory 处理请求和响应 Json 序列化,将对象序列化为Json字符串(此Json序列化,是“不安全的放松JSON转义”,即不会将物特殊符号和中文进行转码) 查询指定数据库中有全部表名,快速定位列名所在表 Sql 查询工具 Sql 数据库表查询 Json 列 显示实体之间的外键关系 调整PowerDesigner各种字体大小 工厂里常说的QC, IQC,IPQC,QA都是干什么的? appsettings.json launchSettings.json 发布 配置
Hangfire 任务调度配置
宁静致远. · 2025-12-11 · via 博客园 - 宁静致远.
app.UseHangfireServer(new BackgroundJobServerOptions
{
    WorkerCount = 10,
}); 

设置任务并行数量:WorkerCount = 10

2. 通过 Dashboard 手动触发 RecurringJob

如果你已经注册了定时任务(RecurringJob),可以在 Hangfire Dashboard 中点击“Trigger now”手动执行一次:

RecurringJob.AddOrUpdate("manual-job", () => Console.WriteLine("定时任务"), Cron.Never());

2. 使用任务依赖链(ContinueWith)

Hangfire 提供 ContinueWith 方法,可以让一个任务在另一个任务完成后执行:

var jobId1 = BackgroundJob.Enqueue(() => Step1());
var jobId2 = BackgroundJob.ContinueWith(jobId1, () => Step2());
var jobId3 = BackgroundJob.ContinueWith(jobId2, () => Step3());