BackgroundTaskExecutor 10.0.14
See the version list below for details.
dotnet add package BackgroundTaskExecutor --version 10.0.14
NuGet\Install-Package BackgroundTaskExecutor -Version 10.0.14
<PackageReference Include="BackgroundTaskExecutor" Version="10.0.14" />
<PackageVersion Include="BackgroundTaskExecutor" Version="10.0.14" />
<PackageReference Include="BackgroundTaskExecutor" />
paket add BackgroundTaskExecutor --version 10.0.14
#r "nuget: BackgroundTaskExecutor, 10.0.14"
#:package BackgroundTaskExecutor@10.0.14
#addin nuget:?package=BackgroundTaskExecutor&version=10.0.14
#tool nuget:?package=BackgroundTaskExecutor&version=10.0.14
BackgroundExecutor
Setting Up
- Add
.AddBackgroundTaskExecutor() - Specify EF Core provider for inner DbContext using
.WithDatabase(options => { }) - Call
.Usemethod to finish DI specification - Add section to your appsettings.json
"BackgroundTaskExecutor": { "Profiles": { "{profileName}": { "Interval": {interval}, "IntervalTimeUnit": {"Millisecond" | "Second" | "Minute" | "Hour" | "Day" }, "FirstRunAfter": {delay}, "FirstRunAfterTimeUnit": {"Millisecond" | "Second" | "Minute" | "Hour" | "Day" }, "LeaseDuration": {duration, optional, 2 minutes by default}, "LeaseDurationTimeUnit": {"Millisecond" | "Second" | "Minute" | "Hour" | "Day" }, } } }
You can override Default profile as well both defining profile with name "Default" or define necessary parameters in "BackgroundTaskExecutor" section
Usage
- Add
[BackgroundExecution({profileName})]attribute to method
Please note that BackgroundExecutor uses DI to get class instance for method running and can pass only CancellationToken to executing method
Several instances
Every instance of the application runs the timers, and each job runs on one of them at a time. A job's lease (the
SyncLeases table, one row per job and profile) is taken with a single conditional update: only when nobody holds
it and the interval has passed since the job last finished. The holder renews it every quarter of LeaseDuration
while the job runs and gives it back when the job ends, so:
- a job that runs longer than its interval never runs on two instances at once;
- an instance that dies mid-run blocks the job only until its lease expires (
LeaseDuration), and an instance that is stopped gives it back at once; - a run that loses its lease (it could not renew in time and another instance took over) is cancelled.
The interval is measured from the end of the last run on any instance. The job is identified by its type, method and
profile, so two jobs that only share a method name no longer block each other. Upgrading from an earlier version
starts each lease from the job's last run in SyncEntries, which is still written as the run log.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.13)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.13)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
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 | |
|---|---|---|---|
| 11.0.0 | 111 | 11/11/2026 | |
| 10.0.14 | 448 | 11/2/2026 | |
| 10.0.13 | 261 | 10/25/2026 | |
| 10.0.3 | 1,137 | 2/19/2026 | |
| 10.0.0 | 896 | 11/12/2025 | |
| 9.0.3 | 2,043 | 3/18/2025 | |
| 9.0.0 | 1,417 | 11/20/2024 | |
| 8.2.0 | 303 | 11/5/2024 | |
| 8.1.1 | 221 | 11/5/2024 | |
| 8.1.0 | 277 | 4/26/2024 | |
| 8.0.2 | 317 | 4/18/2024 | |
| 8.0.1 | 264 | 4/18/2024 | |
| 8.0.0 | 279 | 4/10/2024 |
A job runs on one instance at a time: a lease per job, renewed while it runs and given back when it ends