LinkDotNet.NCronJob
0.10.1
The repository and package moved to a new organization and name. Use NCronJob instead!
Read more about this in our announcement: https://github.com/NCronJob-Dev/NCronJob/discussions/66
See the version list below for details.
dotnet add package LinkDotNet.NCronJob --version 0.10.1
NuGet\Install-Package LinkDotNet.NCronJob -Version 0.10.1
<PackageReference Include="LinkDotNet.NCronJob" Version="0.10.1" />
paket add LinkDotNet.NCronJob --version 0.10.1
#r "nuget: LinkDotNet.NCronJob, 0.10.1"
// Install LinkDotNet.NCronJob as a Cake Addin #addin nuget:?package=LinkDotNet.NCronJob&version=0.10.1 // Install LinkDotNet.NCronJob as a Cake Tool #tool nuget:?package=LinkDotNet.NCronJob&version=0.10.1
<h1 align="center">NCronJob</h1>
<p align="center"> <img src="assets/logo_small.png" alt="logo" width="120px" height="120px"/> <br> <em>Scheduling made easy</em> <br> </p>
NCronJob
A Job Scheduler sitting on top of IHostedService
in dotnet.
Often times one finds themself between the simplicisty of the BackgroundService
/IHostedService
and the complexity of a full blown Hangfire
or Quartz
scheduler.
This library aims to fill that gap by providing a simple and easy to use job scheduler that can be used in any dotnet application and feels "native".
So no need for setting up a database, just schedule your stuff right away! The library gives you two ways of scheduling jobs:
- Instant jobs - just run a job right away
- Cron jobs - schedule a job using a cron expression
Features
- The ability to schedule jobs using a cron expression
- The ability to instantly run a job
- Parameterized jobs - instant as well as cron jobs!
- Integrated in ASP.NET - Access your DI container like you would in any other service
- Get notified when a job is done (either successfully or with an error) - currently in development
Not features
As this is a simple scheduler, some features are not included by design. If you need these features, you might want to look into a more advanced scheduler like Hangfire
or Quartz
.
- Job persistence - Jobs are not persisted between restarts of the application.
- Job history - There is no history of jobs that have been run.
- Retries - If a job fails, it is not retried.
- Progress state - There is no way to track the progress of a job. The library will support notifying when a job is done, but not the progress of the job itself.
Short example
- Import the namespace (or let your IDE do the dirty work)
using LinkDotNet.NCronJob;
- Create a job
public class PrintHelloWorld : IJob
{
private readonly ILogger<PrintHelloWorld> logger;
public PrintHelloWorld(ILogger<PrintHelloWorld> logger)
{
this.logger = logger;
}
public Task Run(JobExecutionContext context, CancellationToken token = default)
{
logger.LogInformation("Hello World");
logger.LogInformation("Parameter: {Parameter}", context.Parameter);
return Task.CompletedTask;
}
}
- Register the NCronJob and the job in your
Program.cs
builder.Services.AddNCronJob();
builder.Services.AddCronJob<PrintHelloWorld>(options =>
{
// Every minute
options.CronExpression = "* * * * * *";
// Optional parameter
options.Parameter = "Hello World";
});
- Run your application and see the magic happen
Triggering an instant job
If the need arises and you want to trigger a job instantly, you can do so:
public class MyService
{
private readonly IInstantJobRegistry jobRegistry;
public MyService(IInstantJobRegistry jobRegistry) => this.jobRegistry = jobRegistry;
public void MyMethod() => jobRegistry.AddInstantJob<MyJob>("I am an optional parameter");
}
Product | Versions 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 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. |
-
net8.0
- Microsoft.Extensions.Hosting (>= 8.0.0)
- NCrontab.Signed (>= 3.3.3)
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 | |
---|---|---|---|
2.4.6 | 546 | 8 months ago | |
2.4.5 | 338 | 8 months ago | |
2.4.4 | 117 | 8 months ago | |
2.4.3-preview | 103 | 8 months ago | |
2.4.1-preview | 100 | 8 months ago | |
2.4.0-preview | 115 | 8 months ago | |
2.3.2 | 241 | 8 months ago | |
2.3.1 | 130 | 8 months ago | |
2.3.0-preview | 123 | 8 months ago | |
2.2.1 | 142 | 8 months ago | |
2.2.0-preview | 129 | 8 months ago | |
2.1.4 | 153 | 8 months ago | |
2.1.3-preview | 113 | 8 months ago | |
2.1.2-preview | 110 | 8 months ago | |
2.1.1-preview | 108 | 8 months ago | |
2.1.0-preview | 110 | 8 months ago | |
2.0.5 | 295 | 9 months ago | |
2.0.4 | 154 | 9 months ago | |
2.0.3 | 139 | 9 months ago | |
2.0.2-preview | 108 | 9 months ago | |
2.0.1-preview | 112 | 9 months ago | |
2.0.0-preview | 139 | 9 months ago | |
1.0.2 | 250 | 9 months ago | |
1.0.1-preview | 121 | 9 months ago | |
1.0.0-preview | 104 | 9 months ago | |
0.13.2 | 158 | 9 months ago | |
0.13.1 | 197 | 9 months ago | |
0.13.0 | 252 | 10 months ago | |
0.12.0 | 161 | 10 months ago | |
0.11.5 | 142 | 10 months ago | |
0.11.4 | 139 | 10 months ago | |
0.11.3 | 126 | 10 months ago | |
0.11.2-preview | 108 | 10 months ago | |
0.11.1-preview | 105 | 10 months ago | |
0.11.0-preview | 117 | 10 months ago | |
0.10.1 | 148 | 10 months ago | |
0.10.0 | 152 | 10 months ago | |
0.9.3 | 133 | 10 months ago | |
0.9.2 | 140 | 10 months ago | |
0.9.1 | 140 | 10 months ago |
Changes in NCronJob #{RELEASE_VERSION}#
#{RELEASE_NOTES}#
See the full changelog at https://github.com/linkdotnet/NCronJob/releases