DotNet Hangfire 定时任务

任务

  • 执行1次,马上执行 BackgroundJob.Enqueue()
var jobId = BackgroundJob.Enqueue(
    () => Console.WriteLine( "job" ));
  • 延迟执行,多少时候后执行 BackgroundJob.Schedule()
var jobId = BackgroundJob.Schedule(
    () => Console.WriteLine( "Delayed!" ),
     TimeSpan.FromDays(7));

-定时执行 RecurringJob.AddOrUpdate()

RecurringJob.AddOrUpdate<Jobs.JcgcJob>(x => x.UpdateJiaTing(), "0 0 23 ? ? ? ", TimeZoneInfo.Local);
  • 顺序执行 BackgroundJob .ContinueJobWith()
BackgroundJob.ContinueJobWith(
    jobId,
    () => Console.WriteLine("Continuation!"));

特性

  • 失败火异常 重试次数
    [AutomaticRetry(Attempts = 2)]

DotNet Hangfire 定时任务

上一篇:.NET---Exceptionless 轻量级的分布式日志管理平台


下一篇:jmeter(3):上传文件(multipart/form-data数据请求)