0
点赞
收藏
分享

微信扫一扫

AspNetCore.TimedJob

十里一走马 2022-03-25 阅读 104
c#.netcore

AspNetCore.TimedJob使用注意事项:

     public class AirConditioningTimerService : Job
    {

    /// <summary>
        /// 报告自动生成 每天执行
        /// </summary>
        [Invoke(Begin = "2022-03-25 18:24:11", Interval = 1000 * 60 * 60 * 24, SkipWhileExecuting = true)]
        public void Report()
        {
            //定时执行
        }

     }

Program文件

 webBuilder.UseStartup<Startup>()
                            .UseDefaultServiceProvider(options => options.ValidateScopes = false); // 添加允许依赖注入,防止timedjob报错,否则无法依赖注入

Startup:

//定时任务
 services.AddTimedJob();

 app.UseTimedJob();

举报

相关推荐

0 条评论