DioRed.Common.Jobs 3.0.1

dotnet add package DioRed.Common.Jobs --version 3.0.1
                    
NuGet\Install-Package DioRed.Common.Jobs -Version 3.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DioRed.Common.Jobs" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DioRed.Common.Jobs" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DioRed.Common.Jobs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DioRed.Common.Jobs --version 3.0.1
                    
#r "nuget: DioRed.Common.Jobs, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DioRed.Common.Jobs@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DioRed.Common.Jobs&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DioRed.Common.Jobs&version=3.0.1
                    
Install as a Cake Tool

DioRed.Common.Jobs

Lightweight in-process scheduling primitives for one-time and recurring jobs (.NET 10+).

Key types

  • ISchedule - stateless schedule definition.
  • Built-in schedules:
    • OneTimeSchedule
    • IntervalSchedule
    • DailySchedule (specific TimeZoneInfo, including DST)
    • LocalTimeDailySchedule (uses TimeZoneInfo.Local)
    • CronSchedule (5- or 6-field CRON)
  • Job - runs an async/sync delegate according to a schedule.

Schedule contract

ISchedule.GetNextOccurrence(DateTimeOffset after) returns the next occurrence that is strictly greater than after. Return null when the schedule is exhausted.

Breaking note

DailySchedule now accepts TimeZoneInfo instead of a fixed UTC offset.

Old shape:

new DailySchedule(new TimeOnly(7, 40), TimeSpan.FromHours(2))

New shape:

new DailySchedule(
    new TimeOnly(7, 40),
    TimeZoneInfo.FindSystemTimeZoneById("Europe/Riga")
)

This change was made so daily schedules can follow real time zone rules and handle DST correctly.

Ambiguous local times during DST fall-back are resolved to the first matching occurrence.

Example (interval)

using DioRed.Common.Jobs;

var job = new Job(
    action: async ct =>
    {
        // Your work here
        await Task.Delay(250, ct);
    },
    schedule: new IntervalSchedule(TimeSpan.FromMinutes(5)),
    options: new JobOptions
    {
        MaxOccurrences = null, // run until cancelled
        TimeProvider = TimeProvider.System
    }
);

job.Scheduled += (_, e) => Console.WriteLine($"Next: {e.NextOccurrence:o}");
job.OccurrenceStarted += (_, e) => Console.WriteLine($"Start #{e.OccurrenceNumber} at {e.StartedAt:o}");
job.OccurrenceFinished += (_, e) => Console.WriteLine($"Finish #{e.OccurrenceNumber} ({e.Duration})");
job.Faulted += (_, e) => Console.WriteLine($"Faulted: {e.Exception}");

var task = job.StartAsync();

// Later:
// job.Cancel();

await task;

Example (cron)

Every day at 03:30 local time:

var job = new Job(
    action: ct => DoSomethingAsync(ct),
    schedule: new CronSchedule("30 3 * * *"),
    options: new JobOptions { MaxOccurrences = null }
);

await job.StartAsync();

Every 10 seconds in UTC:

var job = new Job(
    action: ct => TickAsync(ct),
    schedule: new CronSchedule("*/10 * * * * *", TimeZoneInfo.Utc)
);

await job.StartAsync();

CRON notes

  • Supported fields: *, lists (1,2,3), ranges (1-5), steps (*/5, 1-10/2).
  • Month names: JAN..DEC, day names: SUN..SAT.
  • Day-of-month and day-of-week follow traditional cron semantics:
    • if one of them is a wildcard, the other must match
    • if both are restricted, match if either matches (OR)
    • you can use ? to mark the field as "no specific value".

Misfire handling

If the job wakes up after a scheduled time (for example, machine sleep / long GC pause), it detects a misfire when:

now - scheduledFor > MisfireThreshold (defaults to 1 second).

Choose behavior with JobOptions.MisfirePolicy:

  • Skip (default) — skip missed occurrences.
  • FireOnce — run once immediately, then continue from "now".
  • CatchUp — run missed occurrences sequentially (up to MaxCatchUpExecutions), then continue.
var job = new Job(
    action: ct => WorkAsync(ct),
    schedule: new CronSchedule("0 */5 * * *"),
    options: new JobOptions
    {
        MisfirePolicy = MisfirePolicy.CatchUp,
        MaxCatchUpExecutions = 5,
        MisfireThreshold = TimeSpan.FromSeconds(2)
    }
);

job.Misfired += (_, e) => Console.WriteLine($"Late by {e.Lateness} (policy: {e.Policy})");
await job.StartAsync();
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DioRed.Common.Jobs:

Package Downloads
DioRed.Vermilion.Core

Core engine for Vermilion: message model, command handling pipeline, clients policy and runtime primitives. Use with DioRed.Vermilion.Hosting to run bots in a Generic Host.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 27 4/5/2026
3.0.0 33 4/5/2026
2.0.1 139 12/29/2025
2.0.0 219 12/22/2025
1.8.1 1,168 11/30/2024
1.8.0 292 11/14/2024
1.7.0 1,214 5/22/2024
1.6.0 227 5/22/2024
1.4.2 428 5/10/2024
1.4.1 206 5/10/2024
1.4.0 209 5/10/2024
1.3.0 205 5/10/2024
1.2.0 234 4/6/2024
1.1.1 332 11/16/2023
1.1.0 201 11/16/2023
1.0.0 301 6/6/2023