Woof.CronTimer
6.0.2
Prefix Reserved
See the version list below for details.
dotnet add package Woof.CronTimer --version 6.0.2
NuGet\Install-Package Woof.CronTimer -Version 6.0.2
<PackageReference Include="Woof.CronTimer" Version="6.0.2" />
<PackageVersion Include="Woof.CronTimer" Version="6.0.2" />
<PackageReference Include="Woof.CronTimer" />
paket add Woof.CronTimer --version 6.0.2
#r "nuget: Woof.CronTimer, 6.0.2"
#:package Woof.CronTimer@6.0.2
#addin nuget:?package=Woof.CronTimer&version=6.0.2
#tool nuget:?package=Woof.CronTimer&version=6.0.2
Woof.CronTimer
A very simple timer / scheduler using the cron expression to define schedules.
Features
It was created not to use big schedulers and to make the scheduler completely detached from the scheduled jobs.
It is used like most of the system timers, however instead of interval at least one
ScheduledEvent is needed to make it raise the Impulse events.
The scheduler uses NCrontab library for parsing Cron expressions.
The library is capable of parsing 5 and 6 fields expressions with following formats:
[minute][hour][day of the month][month][day of the week][second][minute][hour][day of the month][month][day of the week]
The correct format is detected automatically while creating the ScheduledEvent.
As the scheduler behaves like most .NET timers, it doesn't use a timer itself. It creates a one long running task awaiting the scheduled events and by default it creates a new task for each event handler to prevent it from blocking the main thread.
If the event handler is asynchronous and it can be guaranteed that it won't block the main
thread, IsImpulseHandledInNewTask property can be set to false to skip creating new tasks
for event handlers. This is an optional performance optimization feture.
The other possible optimization is decreasing the timer resolution by increasing
the TimeSpan assigned to the Resolution property. It checks the schedule every second
that allows extended, 1 second precission expressions to be handled on time. If such
precision is not needed, the time can be increased to lower the power consumption.
The CronTimer class requires a type attribute to specify what type of data will be
bound to a scheduled event. It determines the type of the Data property of the
ScheduledEvent and Impulse event arguments.
When the Impulse event is raised, the assigned data is available in its arguments parameter.
The event list can be modified at runtime ONLY with the
AddEventAsync() and RemoveEventsAsync() methods.
Modifying the list items directly will crash the scheduler.
Those methods should be called only asynchronously. Synchronous calls will obviously deadlock the scheduler.
Usage
- Create
Woof.Cron.CronTimer<T>instance. - Add an
Impulseevent handler. - Add at least one
ScheduledEventtoEventsproperty. - Start the timer with the
Startmethod. - The scheduler can be stopped with
StoporDisposemethod. - The
Disposemethod just stops the timer if it's started to dispose its task and cancellation token source.
Check the demo on GitHub for more details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 was computed. 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. |
-
net5.0
- NCrontab.Signed (>= 3.3.2)
-
net6.0
- NCrontab.Signed (>= 3.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
ADD: ScheduledEvent.Expression is mutable.