Lyo.Scheduler
2.0.0
dotnet add package Lyo.Scheduler --version 2.0.0
NuGet\Install-Package Lyo.Scheduler -Version 2.0.0
<PackageReference Include="Lyo.Scheduler" Version="2.0.0" />
<PackageVersion Include="Lyo.Scheduler" Version="2.0.0" />
<PackageReference Include="Lyo.Scheduler" />
paket add Lyo.Scheduler --version 2.0.0
#r "nuget: Lyo.Scheduler, 2.0.0"
#:package Lyo.Scheduler@2.0.0
#addin nuget:?package=Lyo.Scheduler&version=2.0.0
#tool nuget:?package=Lyo.Scheduler&version=2.0.0
Lyo.Scheduler
In-process scheduler that runs actions at scheduled times. Supports SetTimes, Interval, OneShot, and Cron schedules (5- or 6-field expressions) with logging, metrics, and optional state persistence via ISchedulerStateStore.
Features
- Schedule types.
Interval(periodic inside a window),SetTimes(explicit daily times),OneShot(single run),Cron(5- or 6-field expressions viaLyo.Schedule.Models.CronExpression). - State persistence. In-memory by default. Pluggable
ISchedulerStateStore(e.g. cache-backed) so state survives a restart. - Logging and metrics.
ILoggerandIMetrics. - Background execution. Actions run in the background by default. Optional action timeout.
Examples
How to use it
using Lyo.Scheduler;
using Lyo.Schedule.Models;
// Add to DI (in-memory state store)
services.AddScheduler();
// Or with custom options
services.AddScheduler(options =>
{
options.CheckIntervalMs = 5_000;
options.ActionTimeout = TimeSpan.FromMinutes(10);
options.RunInBackground = true;
});
// Or with a persistent state store (e.g. cache-backed)
services.AddScheduler(myStateStore);
// Add schedules and start
var scheduler = app.Services.GetRequiredService<ISchedulerService>();
scheduler.AddSchedule(
"daily-report",
"Daily Report",
new ScheduleDefinition
{
Type = ScheduleType.SetTimes,
Times = ["09:00", "17:00"],
Timezone = "America/New_York"
},
async ct => await SendDailyReportAsync(ct));
await scheduler.StartAsync();
ISchedulerService methods
| Member | What it does |
|---|---|
AddSchedule(string id, string name, ScheduleDefinition def, Func<CancellationToken,Task> action) |
Add a scheduled action. true when the id is new; false when that id is already registered. |
RemoveSchedule(string id) |
Drop a schedule. |
TryGetSchedule(string id, out ScheduledAction action) / GetSchedules() |
Inspection. |
StartAsync(CancellationToken) / StopAsync(CancellationToken) |
Lifecycle. |
TriggerNowAsync(string id, CancellationToken) |
Run an existing schedule immediately, ignoring cadence. |
GetNextRun(string id, DateTimeOffset? from = null) |
ScheduleCalculator yields the next occurrence for all four schedule types. |
ScheduleCalculator is the evaluator underneath: it dispatches to GetNextRunSetTimes / GetNextRunInterval / GetNextRunOneShot / GetNextRunCron. Cron evaluation first tries
CronFormat.IncludeSeconds (6 fields) and falls back to the standard 5-field format.
Schedule kinds (Lyo.Schedule.Models)
- SetTimes. Fire at specific times each day (e.g. 09:00, 17:00).
- Interval. Fire every N minutes/hours inside a daily window.
- OneShot. Fire once at a specific time.
- Cron. 5-field or 6-field cron (
"0 8 * * MON-FRI","*/30 * * * * *").
Options
| Option | Default | What it controls |
|---|---|---|
| CheckIntervalMs | 10000 | How often (ms) to look for due schedules |
| EnableMetrics | true | Turn metrics on (when IMetrics is registered) |
| RunInBackground | true | Fire-and-forget actions vs await them |
| ActionTimeout | 120 min | Longest each action may run; null = no timeout |
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common.Core(direct, lyo)Lyo.DateAndTime(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Metrics(direct, lyo)Lyo.Schedule.Models(direct, lyo)Microsoft.Extensions.Logging.Abstractions10.0.5(direct, microsoft)Lyo.Common.Metadata(transitive, lyo)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Common.Core (>= 2.0.0)
- Lyo.DateAndTime (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Metrics (>= 2.0.0)
- Lyo.Schedule.Models (>= 2.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
-
net10.0
- Lyo.Common.Core (>= 2.0.0)
- Lyo.DateAndTime (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Metrics (>= 2.0.0)
- Lyo.Schedule.Models (>= 2.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Lyo.Scheduler:
| Package | Downloads |
|---|---|
|
Lyo.Job.Postgres
PostgreSQL persistence for Lyo job management with EF Core, optional auto-migrations, and RabbitMQ event publishing. |
|
|
Lyo.Job.Web.Components
Blazor components library for managing, monitoring, and operating Lyo jobs with MudBlazor integration. |
|
|
Lyo.Schedule.Web.Components
Reusable Blazor components for building, validating, and testing schedule definitions interactively. |
|
|
Lyo.Job.Scheduler
Job scheduling and execution service dispatching jobs via RabbitMQ message queue. |
|
|
Lyo.Scheduler.Cache
Cache-backed state store for Lyo.Scheduler. Persists scheduler state across restarts using Lyo.Cache. |
GitHub repositories
This package is not used by any popular GitHub repositories.