diff --git a/Demo/Startup.cs b/Demo/Startup.cs index 6d9f14a9..ccd89b95 100644 --- a/Demo/Startup.cs +++ b/Demo/Startup.cs @@ -95,26 +95,17 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) .Schedule().Hourly(); scheduler.OnWorker("TestingSeconds"); - // scheduler.Schedule( - // () => Console.WriteLine($"Runs every second. Ran at: {DateTime.UtcNow}") - // ).EverySecond(); - // scheduler.Schedule(() => Console.WriteLine($"Runs every thirty seconds. Ran at: {DateTime.UtcNow}")).EveryThirtySeconds().Zoned(TimeZoneInfo.Local); - // scheduler.Schedule(() => Console.WriteLine($"Runs every ten seconds. Ran at: {DateTime.UtcNow}")).EveryTenSeconds(); - // scheduler.Schedule(() => Console.WriteLine($"Runs every fifteen seconds. Ran at: {DateTime.UtcNow}")).EveryFifteenSeconds(); - // scheduler.Schedule(() => Console.WriteLine($"Runs every thirty seconds. Ran at: {DateTime.UtcNow}")).EveryThirtySeconds(); - // scheduler.Schedule(() => Console.WriteLine($"Runs every minute Ran at: {DateTime.UtcNow}")).EveryMinute(); - // scheduler.Schedule(() => Console.WriteLine($"Runs every 2nd minute Ran at: {DateTime.UtcNow}")).Cron("*/2 * * * *"); + scheduler.Schedule( + () => Console.WriteLine($"Runs every second. Ran at: {DateTime.UtcNow}") + ).EverySecond(); + scheduler.Schedule(() => Console.WriteLine($"Runs every thirty seconds. Ran at: {DateTime.UtcNow}")).EveryThirtySeconds().Zoned(TimeZoneInfo.Local); + scheduler.Schedule(() => Console.WriteLine($"Runs every ten seconds. Ran at: {DateTime.UtcNow}")).EveryTenSeconds(); + scheduler.Schedule(() => Console.WriteLine($"Runs every fifteen seconds. Ran at: {DateTime.UtcNow}")).EveryFifteenSeconds(); + scheduler.Schedule(() => Console.WriteLine($"Runs every thirty seconds. Ran at: {DateTime.UtcNow}")).EveryThirtySeconds(); + scheduler.Schedule(() => Console.WriteLine($"Runs every minute Ran at: {DateTime.UtcNow}")).EveryMinute(); + scheduler.Schedule(() => Console.WriteLine($"Runs every 2nd minute Ran at: {DateTime.UtcNow}")).Cron("*/2 * * * *"); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); - scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); scheduler.Schedule(() => Thread.Sleep(5000)).EverySecond(); }); diff --git a/Src/Coravel/Coravel.csproj b/Src/Coravel/Coravel.csproj index 25c8bf84..67875ac7 100644 --- a/Src/Coravel/Coravel.csproj +++ b/Src/Coravel/Coravel.csproj @@ -2,7 +2,7 @@ .net6.0 Coravel - 5.0.3 + 5.0.4 James Hickey - Coravel diff --git a/Src/Coravel/Scheduling/HostedService/SchedulerHost.cs b/Src/Coravel/Scheduling/HostedService/SchedulerHost.cs index 42861fc8..7f66b981 100644 --- a/Src/Coravel/Scheduling/HostedService/SchedulerHost.cs +++ b/Src/Coravel/Scheduling/HostedService/SchedulerHost.cs @@ -62,8 +62,7 @@ private async void RunSchedulerPerSecondAsync(object state) } if (ticks.Length > 0) - { - this._logger.LogInformation($"Coravel's scheduler is behind {ticks.Length} ticks and is catching-up to the current tick. Triggered at {now.ToString("o")}."); + { foreach (var tick in ticks) { await this._scheduler.RunAtAsync(tick);