Scheduler
Overview
VersaTul.Task.Scheduler provides timer and event primitives for scheduling work on human-friendly intervals.
It is designed for long-running processes such as services, workers, and background jobs where you need explicit control over recurring and one-off execution schedules beyond a simple fixed interval.
When To Use This Package
Use this package when you want to:
Schedule jobs at second, minute, hourly, daily, weekly, or monthly offsets.
Combine multiple schedules into a queue.
Restrict schedules to a time window.
Run background work through a timer abstraction that tracks missed time through stored state.
Installation
Install the package with the .NET CLI:
dotnet add package VersaTul.Task.Scheduler
Or with the Package Manager Console:
PM> NuGet\Install-Package VersaTul.Task.Scheduler -Version latest
Core Types And Concepts
BaseTimerCore timer abstraction that queues and executes scheduled tasks, records last-run state, and raises error events.
ScheduleTimerandReportTimerConcrete timer implementations for general and report-oriented scheduling.
ScheduledEventRepeating schedule built from an
EventTimebase and an offset.IntervalEventFixed interval schedule beginning from an absolute start time.
SingleEventOne-time event.
QueuedEventCollection of schedules treated as one event source.
BlockEventEvent wrapper that limits execution to a defined activity window.
Key Capabilities
Add scheduled tasks through
Add()or delegate-based overloads.Start and stop timers explicitly.
Persist and reuse the last processed time through
Storage.Receive errors through the timer
Errorevent.Compose schedules from multiple event types.
Basic Example
using VersaTul.Task.Scheduler.Events;
using VersaTul.Task.Scheduler.Timers;
var timer = new ScheduleTimer();
timer.Error += (sender, args) =>
{
Console.WriteLine(args.Exception.Message);
};
timer.Add(
new IntervalEvent(DateTime.Now.AddSeconds(10), TimeSpan.FromMinutes(2)),
(Action)(() => Console.WriteLine($"Executed at {DateTime.Now}")));
timer.Start();
Scheduled Event Example
var hourlyQuarterPast = new ScheduledEvent(EventTime.Hourly, new TimeSpan(0, 15, 0));
var nextRun = hourlyQuarterPast.NextEvent(DateTime.Now, includeStartTime: true);
Notes
BaseTimeruses a non-autoresetting internal timer and continually queues the next interval itself.Storagedefaults toLocalEventStoragebut can be replaced.The scheduler is a good fit for service-style orchestration, not full workflow persistence.