Com.H.Threading.Scheduler
11.0.1
dotnet add package Com.H.Threading.Scheduler --version 11.0.1
NuGet\Install-Package Com.H.Threading.Scheduler -Version 11.0.1
<PackageReference Include="Com.H.Threading.Scheduler" Version="11.0.1" />
<PackageVersion Include="Com.H.Threading.Scheduler" Version="11.0.1" />
<PackageReference Include="Com.H.Threading.Scheduler" />
paket add Com.H.Threading.Scheduler --version 11.0.1
#r "nuget: Com.H.Threading.Scheduler, 11.0.1"
#:package Com.H.Threading.Scheduler@11.0.1
#addin nuget:?package=Com.H.Threading.Scheduler&version=11.0.1
#tool nuget:?package=Com.H.Threading.Scheduler&version=11.0.1
Com.H.Threading.Scheduler
For full documentation, visit the GitHub project page.
An easy-to-use, feature-rich, open-source scheduling framework for building background services as Windows services, Linux daemons, or containerized microservices.
Quick start
Define tasks in an XML configuration file with scheduling rules in <sys> and custom data in any other tags:
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>
Program.cs
using Com.H.Threading.Scheduler;
var configPath = Path.Combine(AppContext.BaseDirectory, "scheduler.xml");
if (!File.Exists(configPath)) throw new FileNotFoundException(configPath);
var scheduler = new HTaskScheduler(configPath);
scheduler.TaskIsDue += async (object sender, HTaskEventArgs e, CancellationToken ct) =>
{
Console.WriteLine(e["greeting_message"]);
};
Console.WriteLine("Press <ctrl+c> to exit.");
await scheduler.StartAsync();
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, the same as <dom>1</dom> |
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 |
Before 11.0.1 bom was read but never acted on, so a task with <bom>true</bom> ran every day.
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 (HTaskScheduler.DefaultSleepOnError). 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., 3600000).
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
scheduler.TaskExecutionError += async (object sender, HTaskExecutionErrorEventArgs e, CancellationToken ct) =>
{
Console.WriteLine($"Task failed: {e.Exception.Message}");
};
scheduler.TaskLoadingError += async (object sender, HErrorEventArgs e, CancellationToken ct) =>
{
Console.WriteLine($"Config error: {e.Exception.Message}");
};
Worker service integration
For .NET worker services, use Com.H.Threading.Scheduler.DI for IServiceCollection integration. Installing it automatically includes this library as a dependency.
| 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. |
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Com.H.Threading.Scheduler:
| Package | Downloads |
|---|---|
|
Com.H.Threading.Scheduler.DI
Dependency injection extension for Com.H.Threading.Scheduler API to facilitate easier usage for applications that utilize IHostBuilder services DI pipeline |
|
|
Com.H.Threading.Scheduler.VP.Sql
Sql server value processor for Com.H.Threading.Scheduler library |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1 | 115 | 11/12/2026 |
| 11.0.0 | 145 | 11/11/2026 |
| 10.1.1 | 190 | 8/23/2026 |
| 10.0.1 | 235 | 4/15/2026 |
| 10.0.0 | 158 | 4/15/2026 |
| 9.0.0.1 | 298 | 9/8/2025 |
| 9.0.0 | 271 | 12/9/2024 |
| 8.0.0.3 | 268 | 11/29/2024 |
| 8.0.0.2 | 309 | 9/24/2024 |
| 8.0.0.1 | 292 | 9/24/2024 |
| 8.0.0 | 499 | 1/29/2024 |
| 6.0.6.4 | 1,328 | 9/3/2022 |
| 6.0.6.3 | 1,101 | 8/27/2022 |
| 6.0.6.2 | 1,076 | 8/27/2022 |
| 6.0.6.1 | 1,035 | 8/27/2022 |
| 5.0.17.2 | 1,083 | 8/27/2022 |
| 1.0.10 | 1,507 | 1/24/2022 |
| 1.0.9 | 1,346 | 5/8/2021 |
| 1.0.8 | 1,317 | 1/3/2021 |
| 1.0.7 | 1,299 | 1/3/2021 |
11.0.1
* Fixed: bom (the first day of the month) was read and documented but never acted on, in any
version. A task with bom set to true ran every day. It now runs on the 1st only. If a task of
yours has bom and you came to rely on it running daily, take the tag out.
* New: IHTaskControlProperties.FirstDayOfMonth, which is what the engine now looks at. It has a
default (null), so your own implementation of the interface still compiles and loads unchanged.
11.0.0
A task whose handler throws is handled differently. If you relied on a failing task being tried
again every second, set sleep_on_error to your tick interval.
* 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, and the package now depends on Com.H 11.0.x.
* Fixed: a task that threw was tried again on every tick (every second by default), whatever its
schedule, unless both retry_attempts_on_error and sleep_on_error were set. It now waits before
the next try: for sleep_on_error if set, otherwise for its interval, otherwise for
HTaskScheduler.DefaultSleepOnError (new, 60 seconds).
* Fixed: sleep_on_error was ignored without retry_attempts_on_error.
* Fixed: a task that used up its retry_attempts_on_error did not run again (a task that had never
succeeded: not until its XML changed). It now waits for its next scheduled time and starts it
with a full count. retry_attempts_on_error 0 means no retries.
* Fixed: a task that last ran before today and failed today lost its retry count and the time of
its last error on every save of the log, so its retry settings had no effect.
* Changed: an exception from a handler is reported through TaskExecutionError and nowhere else,
with or without retry settings. Before, without retry_attempts_on_error it was also rethrown,
from a task that nothing awaits.
* Fixed: a handler stopped by the scheduler's own shutdown was counted as a failure.
* Fixed: the constructor taking an IHTaskCollection threw on start, for want of a config path.
* New: HTaskScheduler.ValueProcessors registers custom value processors before the start.