VersaTul.Task.Scheduler 1.0.23

Prefix Reserved
dotnet add package VersaTul.Task.Scheduler --version 1.0.23                
NuGet\Install-Package VersaTul.Task.Scheduler -Version 1.0.23                
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="VersaTul.Task.Scheduler" Version="1.0.23" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VersaTul.Task.Scheduler --version 1.0.23                
#r "nuget: VersaTul.Task.Scheduler, 1.0.23"                
#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.
// Install VersaTul.Task.Scheduler as a Cake Addin
#addin nuget:?package=VersaTul.Task.Scheduler&version=1.0.23

// Install VersaTul.Task.Scheduler as a Cake Tool
#tool nuget:?package=VersaTul.Task.Scheduler&version=1.0.23                

VersaTul Task Scheduler

VersaTul Task Scheduler is a project that provides functionality to schedule events then listen to and react to those events. This is ideal for windows service type applications that may run tasks based on certain time or day.

Installation

To use VersaTul Task Scheduler, first install it using nuget:

Install-Package VersaTul.TaskScheduler

Usage

VersaTul Task Scheduler consists of several classes that represent different types of events and timers. Here is a brief overview of each class:

  • BaseTimer: Abstract class that represents a timer that fires on a more human friendly schedule. For example it is easy to set it to fire every day at 6:00PM. It is useful for batch jobs or alarms that might be difficult to schedule with the native DOTNET timers. It is also similar to the DOTNET timer in that it has start and stop methods functioning similarly. The main difference is that the event uses a different delegate and argument since the DOTNET timer argument class is not create-able.
  • ScheduleTimer: Implements BaseTimer and provides the ability to schedule events.
  • ReportTimer: Implements BaseTimer and provides the ability to schedule events that are reporting specific. Provides the ability to pass a Report Identifier to run a specified report.
  • BlockEvent: Represents a class that can filter events so they are only enabled at a certain window of activity. For example if an event should only run every 15 minutes between 6:00 AM and 5:00 PM. Or just on weekdays or weekends.
  • IntervalEvent: Represents the simple scheduling that DOTNET supports natively. It consists of a start absolute time and an interval that is counted off from the start time.
  • QueuedEvent: Represents a collection of scheduled events. This is useful for events that occur every 10 minutes or at multiple intervals not covered by the simple scheduled items.
  • ScheduledEvent: Represents a simple schedule. It can also represent a repeating event that occurs anywhere from every second to once a month. For example new ScheduledEvent (Hourly, new TimeSpan (0, 15, 0)) would represent an event that fired 15 minutes after the hour every hour.
  • SingleEvent: Represents a single event that occurs at a specific time.

To use these classes, you need to create an instance of the ScheduleTimer class and add events to it using the AddEvent method. You can also use the AddSyncronized method to add events that operate asynchronously. Then you need to call the Start method to begin executing the assigned tasks at the scheduled times.

Here is a simple example of using ScheduleTimer in a BackgroundService:

public class MyService : BackgroundService
{
    private readonly ScheduleTimer _timer;

    public MyService()
    {
        _timer = new ScheduleTimer();
        _timer.AddEvent(new ScheduledEvent(Daily, new TimeSpan(18, 0, 0)), OnDailyEvent);
        _timer.AddEvent(new ScheduledEvent(Hourly, new TimeSpan(0, 15, 0)), OnHourlyEvent);
    }

    protected override Task ExecuteAsync(CancellationToken stoppingToken)
    {
        _timer.Start();
        return Task.CompletedTask;
    }

    private void OnDailyEvent(object sender, TimerEventArgs e)
    {
        // Do something every day at 6:00 PM
    }

    private void OnHourlyEvent(object sender, TimerEventArgs e)
    {
        // Do something every hour at 15 minutes past the hour
    }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.23 83 12/10/2024
1.0.22 154 4/4/2024
1.0.21 110 4/4/2024
1.0.20 137 3/1/2024
1.0.19 114 2/2/2024
1.0.18 113 1/25/2024
1.0.17 115 1/23/2024
1.0.16 113 1/23/2024
1.0.15 116 1/15/2024
1.0.14 115 1/11/2024
1.0.13 118 1/11/2024
1.0.12 115 1/11/2024
1.0.11 131 12/16/2023
1.0.10 176 11/2/2023
1.0.9 188 7/24/2023
1.0.8 165 7/22/2023