HakanUcaar / Cronable

Add cron job ability to your class methods

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cronable

Add cron job ability to your class methods

Usage

Implement

    public interface ITest : ICronable
    {
    }
    
    public class Test : ITest
    {
        public List<ICronJob> CronJobs { get; set; } = new();
      
        //My Attribute trigger every minute
        [CronJob("* * * * *")]
        public void TestMethod()
        {
            Console.WriteLine("TestMethod execute");
        }
        
        //My Attribute trigger every minute
        [CronJob("* * * * *")]
        public Task Test2Method()
        {
            return Task.Run(()=> Console.WriteLine("TestMethod2 execute"));
        }
    }  

Start jobs

  testClass.RegisterJobs().StartJobsAsync(CancellationToken.None);

Output

  TestMethod execute
  TestMethod2 execute

referance repo : https://github.com/furkandeveloper/EasyCronJob

About

Add cron job ability to your class methods

License:MIT License


Languages

Language:C# 100.0%