安装:FluentScheduler

Install-Package FluentScheduler

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentScheduler;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            //两个参数分别:Job、调度时间
            JobManager.AddJob(() =>
            {
                //任务逻辑
                Console.WriteLine("Timer task,current time:{0}", DateTime.Now);
            }, t =>
            {
                //时间

                //从程序启动开始执行,然后每秒钟执行一次
                t.ToRunNow().AndEvery(1).Seconds();
                ////带有任务名称的任务定时器
                //t.WithName("TimerTask").ToRunOnceAt(DateTime.Now.AddSeconds(5));
            });


            Console.ReadKey();
        }
    }
}
program.cs

相关文章:

  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案