protected static void Main(string[] args) { var taskScanner = new CrontabTaskScaner(); var tasks = taskScanner.ScanTasks(); if (tasks != null) { foreach (var task in tasks) { Console.WriteLine($"{task.ClassType}, {task.Method.Name}, {task.Cron.Expression}, {task.Cron.Format}"); } Console.WriteLine($"{tasks.Count}"); } Console.ReadKey(); var executor = new CrontabTaskExecutor(m => { var classType = m.DeclaringType; return(classType == typeof(TestScheduler) ? new TestScheduler() : null); }); executor.AddTasks(tasks); executor.Run(); while (true) { // exit when press 'Q' if (Console.ReadKey().Key == ConsoleKey.Q) { break; } executor.Stop(); Console.ReadKey(); executor.Run(); } }
public static void Task4(DateTime time, CrontabTask task, CrontabTaskExecutor taskExecutor) { Debug.WriteLine($"Task..............Cron_{time}_{task.Method.Name}_{taskExecutor.Tasks.Count}"); }