Com.H.Threading.Scheduler.DI
11.0.0
See the version list below for details.
dotnet add package Com.H.Threading.Scheduler.DI --version 11.0.0
NuGet\Install-Package Com.H.Threading.Scheduler.DI -Version 11.0.0
<PackageReference Include="Com.H.Threading.Scheduler.DI" Version="11.0.0" />
<PackageVersion Include="Com.H.Threading.Scheduler.DI" Version="11.0.0" />
<PackageReference Include="Com.H.Threading.Scheduler.DI" />
paket add Com.H.Threading.Scheduler.DI --version 11.0.0
#r "nuget: Com.H.Threading.Scheduler.DI, 11.0.0"
#:package Com.H.Threading.Scheduler.DI@11.0.0
#addin nuget:?package=Com.H.Threading.Scheduler.DI&version=11.0.0
#tool nuget:?package=Com.H.Threading.Scheduler.DI&version=11.0.0
Com.H.Threading.Scheduler.DI
Dependency injection extension for Com.H.Threading.Scheduler — provides IServiceCollection integration for .NET worker services hosted as Windows services, Linux daemons, or containerized microservices.
Visit the GitHub page for full documentation.
Quick start
1. Create the XML configuration
scheduler.xml
<?xml version="1.0" encoding="utf-8" ?>
<tasks_list>
<task>
<sys>
<time>11:00</time>
</sys>
<greeting_message>Good morning! It's 11:00 AM!</greeting_message>
</task>
</tasks_list>
2. Register the scheduler in DI
Program.cs
using Com.H.Threading.Scheduler;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddSchedulerService(options =>
{
options.ConfigPath = Path.Combine(AppContext.BaseDirectory, "scheduler.xml");
});
builder.Services.AddHostedService<Worker>();
var host = builder.Build();
host.Run();
3. Inject and use in a worker
Worker.cs
using Com.H.Threading.Scheduler;
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private readonly ISchedulerService _scheduler;
public Worker(ILogger<Worker> logger, ISchedulerService scheduler)
{
_logger = logger;
_scheduler = scheduler;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_scheduler.IsDue += async (object sender, HTaskEventArgs e, CancellationToken ct) =>
{
_logger.LogInformation(e["greeting_message"]);
};
await _scheduler.StartAsync(stoppingToken);
}
}
Scheduling features
All scheduling features come from the base Com.H.Threading.Scheduler library (included automatically as a dependency).
Interval scheduling
Run every 3 seconds between 9:00 AM and 2:00 PM on specific days:
<sys>
<time>09:00</time>
<until_time>14:00</until_time>
<interval>3000</interval>
<dow>Monday,Thursday</dow>
</sys>
Scheduling rules
All rules compose — every condition must be true for a task to run.
| Tag | Description | Format | Example |
|---|---|---|---|
enabled |
Enable or disable the task | true / false |
true |
not_before |
Earliest date/time to run | yyyy-MM-dd HH:mm:ss |
2026-06-01 08:00:00 |
not_after |
Latest date/time to run | yyyy-MM-dd HH:mm:ss |
2026-12-31 23:59:59 |
dates |
Specific dates (pipe-delimited) | yyyy-MM-dd |
2026-01-15\|\|2026-07-04 |
doy |
Days of the year | Integer 1–366 | 1,60,120..130 |
eom |
Last day of month | true / false |
true |
bom |
First day of month | true / false |
true |
dom |
Days of the month | Integer 1–31 | 1,15,28..31 |
dow |
Days of the week | Weekday names | Monday,Friday |
time |
Start time | HH:mm |
14:30 |
until_time |
End time | HH:mm |
23:00 |
interval |
Milliseconds between runs | Positive integer | 5000 |
ignore_log_on_restart |
Force re-run on restart | true / false |
true |
Retry on error
<sys>
<interval>10000</interval>
<retry_attempts_on_error>3</retry_attempts_on_error>
<sleep_on_error>5000</sleep_on_error>
</sys>
A task that throws is tried again after a pause: sleep_on_error if set, otherwise its interval, otherwise 60 seconds (the DefaultSleepOnError option). retry_attempts_on_error limits the retries; without it there is no limit. When the retries are used up, the task waits for its next scheduled time and starts again with a full count.
Before 11.0.0 a task that threw was tried again on every tick unless both tags were set, and a task that used up its retries did not run again.
Variables
Built-in placeholders replaced at runtime:
| Variable | Example | Result |
|---|---|---|
{now{yyyy-MM-dd}} |
{now{yyyy-MM-dd}} |
2026-04-15 |
{tomorrow{yyyy-MM-dd}} |
{tomorrow{yyyy-MM-dd}} |
2026-04-16 |
{dir{sys}} |
{dir{sys}}\data |
C:\app\bin\data |
{dir{uri}} |
{dir{uri}}/data |
file:///C:/app/bin/data |
Repeat
Execute a task multiple times with different data per iteration. Supports XML (default), JSON, CSV, and pipe-separated formats:
<sys>
<interval>60000</interval>
<repeat content_type="json" delay_interval="500">
[
{"id": 1, "name": "alice"},
{"id": 2, "name": "bob"}
]
</repeat>
</sys>
<message>Processing {var{name}} (ID: {var{id}})</message>
Repeat from external source
Chain content types to fetch and parse: uri > json, uri > csv, uri > xml, etc.
<repeat content_type="uri > json" delay_interval="500">
https://api.example.com/users
</repeat>
File URIs are also supported:
<repeat content_type="uri > csv" delay_interval="500">
{dir{uri}}/data/users.csv
</repeat>
External settings
Fetch tag content from URLs with optional caching:
<config content_type="uri" content_cache="once_per_day">
https://api.example.com/config
</config>
Cache options: none (default), once_per_day / daily, or milliseconds (e.g., content_cache="60000" for 60 seconds).
Dynamic scheduling with URI — skip holidays
content_type="uri" also works on scheduling rules inside <sys>. Point <enabled> at an API — if the response contains true (case-insensitive), the task runs; otherwise it's skipped:
<sys>
<time>09:00</time>
<dow>Monday,Tuesday,Wednesday,Thursday,Friday</dow>
<enabled content_type="uri">https://api.example.com/is-business-day?date={now{yyyy-MM-dd}}</enabled>
</sys>
Add content_cache="once_per_day" to avoid calling the API on every tick — the result is cached until midnight:
<enabled content_type="uri" content_cache="once_per_day">https://api.example.com/is-business-day?date={now{yyyy-MM-dd}}</enabled>
Custom placeholder markers
Override the default {{ / }} markers on any tag:
<sql open-marker="[%" close-marker="%]" null-value="N/A">
INSERT INTO users (name, email) VALUES ('[%var{name}%]', '[%var{email}%]')
</sql>
Error handling
Worker.cs
_scheduler.TaskExceptionError += async (object sender, HTaskExecutionErrorEventArgs e, CancellationToken ct) =>
{
_logger.LogError($"Task failed: {e.Exception.Message}");
};
_scheduler.TaskLoadingError += async (object sender, HErrorEventArgs e, CancellationToken ct) =>
{
_logger.LogError($"Config error: {e.Exception.Message}");
};
See the full documentation for more examples and details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. net11.0 is compatible. |
-
net10.0
- Com.H (>= 11.0.0 && < 11.1.0)
- Com.H.Threading.Scheduler (>= 11.0.0 && < 11.1.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
-
net11.0
- Com.H (>= 11.0.0 && < 11.1.0)
- Com.H.Threading.Scheduler (>= 11.0.0 && < 11.1.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
-
net8.0
- Com.H (>= 11.0.0 && < 11.1.0)
- Com.H.Threading.Scheduler (>= 11.0.0 && < 11.1.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
-
net9.0
- Com.H (>= 11.0.0 && < 11.1.0)
- Com.H.Threading.Scheduler (>= 11.0.0 && < 11.1.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1 | 109 | 11/12/2026 |
| 11.0.0 | 142 | 11/11/2026 |
| 10.1.0 | 210 | 4/15/2026 |
| 10.0.0 | 140 | 4/15/2026 |
| 9.0.0.1 | 275 | 9/8/2025 |
| 9.0.0 | 262 | 12/9/2024 |
| 8.0.0.4 | 221 | 11/29/2024 |
| 8.0.0.3 | 226 | 9/24/2024 |
| 8.0.0.2 | 235 | 9/24/2024 |
| 8.0.0.1 | 244 | 9/24/2024 |
| 8.0.0 | 290 | 1/29/2024 |
| 6.0.0.2 | 645 | 9/3/2022 |
| 1.0.5 | 706 | 1/24/2022 |
| 1.0.4 | 593 | 5/8/2021 |
| 1.0.3 | 628 | 1/3/2021 |
| 1.0.2 | 602 | 1/3/2021 |
| 1.0.1 | 660 | 1/2/2021 |
| 1.0.0 | 649 | 12/17/2020 |
11.0.0
* New: a net11.0 build, for .NET 11. The net8.0, net9.0 and net10.0 builds stay. The major version
is 11 because it follows the .NET generation.
* Now on Com.H.Threading.Scheduler 11.0.x, which changes what happens to a task whose handler
throws: it is tried again after a pause instead of on every tick, and a task that used up its
retry_attempts_on_error runs again at its next scheduled time. If you relied on a failing task
being tried again every second, set sleep_on_error to your tick interval. The scheduler's notes
list every change: https://www.nuget.org/packages/Com.H.Threading.Scheduler/11.0.0#releasenotes-body-tab
* Fixed: SchedulerServiceOptions.ValueProcessors had no effect. The processors are now used, and
one with the name of a built-in processor replaces it.
* New: SchedulerServiceOptions.DefaultSleepOnError sets the pause for a failed task that has
neither sleep_on_error nor an interval (the scheduler's default is 60 seconds).
* Dependencies: Com.H 11.0.x, and Microsoft.Extensions.DependencyInjection and
Microsoft.Extensions.Options 10.0.11 or later (they were 8.0.0 or later).