mvdmio.ASP.Jobs 4.1.2

dotnet add package mvdmio.ASP.Jobs --version 4.1.2
                    
NuGet\Install-Package mvdmio.ASP.Jobs -Version 4.1.2
                    
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="mvdmio.ASP.Jobs" Version="4.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="mvdmio.ASP.Jobs" Version="4.1.2" />
                    
Directory.Packages.props
<PackageReference Include="mvdmio.ASP.Jobs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add mvdmio.ASP.Jobs --version 4.1.2
                    
#r "nuget: mvdmio.ASP.Jobs, 4.1.2"
                    
#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.
#:package mvdmio.ASP.Jobs@4.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=mvdmio.ASP.Jobs&version=4.1.2
                    
Install as a Cake Addin
#tool nuget:?package=mvdmio.ASP.Jobs&version=4.1.2
                    
Install as a Cake Tool

mvdmio.ASP.Jobs

A library for scheduling jobs in ASP.NET Core applications.

Usage

  1. Add the NuGet package to your project:
dotnet add package mvdmio.ASP.Jobs
  1. Register the job scheduler and job runner in your Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
   services.AddJobs();
   -- OR --
   services.AddJobScheduler();
   services.AddJobRunner();
}
  1. Create a job by implementing the Job abstract class:
public class MyJobParameters
{
   public string Parameter { get; set; }
}

public class MyJob : Job<MyJobParameters>
{
    public async Task ExecuteAsync(MyJobParameters parameters, CancellationToken cancellationToken)
    {
        // Your job logic here
    }
}
  1. Register the job in your DI container:
public void ConfigureServices(IServiceCollection services)
{
   services.RegisterJob<MyJob>();
}
  1. Schedule the job in your application:
public void MyController : Controller
{
   private readonly IJobScheduler _jobScheduler;

   public MyController(IJobScheduler jobScheduler)
   {
      _jobScheduler = jobScheduler;
   }

   public async Task<IActionResult> ScheduleJob()
   {
      await _jobScheduler.PerformNowAsync<MyJob, MyJobParameters>(new MyJobParameters());  // Runs the job immediately and waits for completion.
      await _jobScheduler.PerformAsapAsync<MyJob, MyJobParameters>(new MyJobParameters()); // Runs the job on a separate thread as soon as a slot becomes available.
      await _jobScheduler.PerformAtAsync<MyJob, MyJobParameters>(DateTime.Now, new MyJobParameters());  // Runs the job on a separate thread at the given time.

      return Ok();
   }
}

Scheduled jobs (CRON)

You can schedule any job to run repeatedly using CRON expressions.

This library uses the Cronos nuget package to parse CRON expressions.

To schedule a job to run repeatedly, use the PerformCronAsync method on the IJobScheduler interface. Usually this is done during application startup.

var jobScheduler = application.Services.GetRequiredService<IJobScheduler>();
jobScheduler.PerformCronAsync<MyJob>("* * * * * *", new MyJobParameters()); // Run every second
jobScheduler.PerformCronAsync<MyJob>("* * * * *", new MyJobParameters());   // Run every minute
jobScheduler.PerformCronAsync<MyJob>("*/5 * * * *", new MyJobParameters()); // Run every 5 minutes
jobScheduler.PerformCronAsync<MyJob>("0 * * * *", new MyJobParameters());   // Run once an hour at the beginning of the hour
jobScheduler.PerformCronAsync<MyJob>("0 0 * * *", new MyJobParameters());   // Run once a day at midnight
jobScheduler.PerformCronAsync<MyJob>("0 0 * * 0", new MyJobParameters());   // Run once a week at midnight on Sunday morning
jobScheduler.PerformCronAsync<MyJob>("0 0 1 * *", new MyJobParameters());   // Run once a month at midnight of the first day of the month

.NET Framework

It is possible to use this library in .NET Framework applications. However, since those applications don't generally use Dependency Injection you can use the static Jobs class for registering jobs, scheduling jobs, and starting the job runner process.

// In your application startup code
Jobs.Register<MyJob>(); // All jobs must be registered before starting the job runner
Jobs.Start();
    
// In you application shutdown code
Jobs.Stop();

// In your application code
Jobs.Scheduler.PerformNow<MyJob, MyJobParameters>(new MyJobParameters());
Jobs.Scheduler.PerformAsap<MyJob, MyJobParameters>(new MyJobParameters());
Jobs.Scheduler.PerformAt<MyJob, MyJobParameters>(DateTime.Now, new MyJobParameters());
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.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on mvdmio.ASP.Jobs:

Package Downloads
mvdmio.HealthCheck.Client

Client library for mvdm.io HealthCheck.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.2 46 5/3/2026
4.1.1 49 5/2/2026
4.1.0 147 4/25/2026
4.0.7 84 4/25/2026
4.0.6 680 2/27/2026
4.0.5 165 2/18/2026
4.0.4 125 2/16/2026
4.0.3 348 2/5/2026
4.0.2 136 2/4/2026
4.0.1 109 2/4/2026
4.0.0 122 2/3/2026
4.0.0-beta.1 60 2/3/2026
3.9.1 186 1/23/2026
3.9.0 95 1/23/2026
3.8.2 108 1/21/2026
3.8.1 120 1/20/2026
3.8.0 106 1/18/2026
3.7.0 98 1/17/2026
3.6.3 120 1/17/2026
3.6.2 401 10/14/2025
Loading failed