![]() |
VOOZH | about |
dotnet add package Simplify.Scheduler --version 1.7.0
NuGet\Install-Package Simplify.Scheduler -Version 1.7.0
<PackageReference Include="Simplify.Scheduler" Version="1.7.0" />
<PackageVersion Include="Simplify.Scheduler" Version="1.7.0" />Directory.Packages.props
<PackageReference Include="Simplify.Scheduler" />Project file
paket add Simplify.Scheduler --version 1.7.0
#r "nuget: Simplify.Scheduler, 1.7.0"
#:package Simplify.Scheduler@1.7.0
#addin nuget:?package=Simplify.Scheduler&version=1.7.0Install as a Cake Addin
#tool nuget:?package=Simplify.Scheduler&version=1.7.0Install as a Cake Tool
Same as Simplify.WindowsServices library with removed Windows Services dependency and specifically made for console (docker) execution.
Provides BasicScheduler, SingleTaskScheduler, MultitaskScheduler classes for scheduling.
Allows you to simply create applications which can work on schedule. Every user class instance will be instantiated using Simplify.DI IOC container which provides DI by default for your application.
Available at NuGet as binary package
To use Simplify.Scheduler, you must create a class with the Run method in it and pass this class to the handler as a type parameter. The Run method will be invoked by the handler class (the handler types are listed below). This method will be your execution process root. An instance of your class will be created using the IOC Simplify.DI container, so you can register any types that your class depends on through DIContainer.Current, and they will be automatically resolved.
Run method can be one of the following:
Run() method.Run(string serviceName) if you want to access a service name.Run(IJobArgs args) if you want to access a service name or startup parameters.The Run method can be void or can return Task (can be used for async/await code).
There is a templates package available at nuget.org for Simplify.Scheduler.
Install Simplify.ProjectsTemplates templates package:
dotnet new -i Simplify.ProjectsTemplates
Create an initial Simplify.Scheduler-based project:
dotnet new simplify.scheduler -n HelloWorld
BasicScheduler class is best suited for services that run without timers, for example, a TCP server or client.
SingleTaskScheduler class is best suited to perform one task, which must be periodically started by a timer.
MultitaskScheduler class is best suited for multiple task services.
This is the same as SingleTaskScheduler but allows you to specify multiple working classes/methods.
You can add multiple jobs with different timer intervals/crontab expressions.
You can use a single class with several methods, each specified method will be launched by the corresponding task (a new instance of the class will be created), or simply use several classes.
MultitaskScheduler working example
You can specify timer intervals in seconds or just set the Ncrontab expression for the timer. If no settings are specified in the configuration, then the timer will be executed once every minute. If both timer interval and crontab expression are specified in the config, then the crontab expression will be used instead.
Multiple crontab expressions can be specified, for example: 30 14 * * *|45 1 * * *|0 12 * * Mon
The main way to set up a job is to pass configuration based on Microsoft.Extensions.Configuration.IConfiguration.
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", false)
.Build();
using(var handler = new SingleTaskScheduler<MyClass>(configuration))
handler.Start();
{
"JobSettings":
{
"CrontabExpression": "* * * * *",
"ProcessingInterval": 30
}
}
| Option | Default Value | Description |
|---|---|---|
| CleanupOnTaskFinish | true | Execute GC.Collect(); after each "Run" method execution |
| MaximumParallelTasksCount | 1 (so only one task of the same job can exist at a time) | The maximum allowed parallel tasks of the same job (a new task will be created in parallel if the previous task has not finished execution) |
Simplify.Scheduler can catch all exceptions thrown by user code.
To receive such an event, you should subscribe to the handler's OnException event.
static void Main(string[] args)
{
...
handler.OnException += OnException;
...
}
static void OnException(SchedulerExceptionArgs args)
{
Console.Write(args.AppName);
Console.Write(args.Exception.Message);
}
public class MyClass
{
public void Run()
{
// Some task
}
}
static void Main(string[] args)
{
DIContainer.Current.Register<MyClass>();
using(var scheduler = new BasicScheduler<MyClass>())
scheduler.Start(args);
}
SingleTaskScheduler<T> requires an IConfiguration instance.
static void Main(string[] args)
{
DIContainer.Current.Register<MyClass>();
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", false)
.Build();
using(var scheduler = new SingleTaskScheduler<MyClass>(configuration))
scheduler.Start(args);
}
static void Main(string[] args)
{
// Registering in IOC container
DIContainer.Current.Register<TaskProcessor1>();
DIContainer.Current.Register<TaskProcessor2>();
// Handler creation
using(var handler = new MultitaskScheduler())
{
// Jobs addition
// If configuration section is not specified then 'YourClassName + Settings' section name will be used
handler.AddJob<TaskProcessor1>();
// Manually specified section name and invoke method name
handler.AddJob<TaskProcessor1>("TaskProcessor1SecondTaskSettings", "RunTask2");
handler.AddJob<TaskProcessor2>();
handler.Start(args);
}
}
public class TaskProcessor1
{
public void Run()
{
Debug.WriteLine("TaskProcessor1 Run executed");
}
public void RunTask2()
{
Debug.WriteLine("TaskProcessor1 RunTask2 executed");
}
}
public class TaskProcessor2
{
public void Run()
{
Debug.WriteLine("TaskProcessor2 Run executed");
}
}
{
"TaskProcessor1Settings": {
"CrontabExpression": "*/2 * * * *"
},
"TaskProcessor1SecondTaskSettings": {
"ProcessingInterval": 30
},
"TaskProcessor2Settings": {
"ProcessingInterval": 45
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.7.0 | 49 | 6/25/2026 |
| 1.6.1 | 409 | 10/11/2025 |
| 1.6.0 | 303 | 6/15/2025 |
| 1.5.0 | 1,477 | 6/2/2024 |
| 1.4.0 | 494 | 1/9/2024 |
| 1.3.1 | 406 | 8/24/2023 |
| 1.3.0 | 2,074 | 11/18/2021 |
| 1.2.0 | 998 | 5/25/2021 |
| 1.1.2 | 576 | 5/24/2021 |
| 1.1.0 | 887 | 2/4/2021 |
| 1.0.1 | 585 | 2/2/2021 |
| 1.0.0 | 1,169 | 6/27/2020 |
| 1.0.0-pre05 | 665 | 12/9/2019 |
| 1.0.0-pre03 | 648 | 9/26/2019 |
| 1.0.0-pre02 | 604 | 9/12/2019 |
| 1.0.0-pre01 | 611 | 8/25/2019 |