Decode.Hosting.Abstractions 3.0.0

dotnet add package Decode.Hosting.Abstractions --version 3.0.0
                    
NuGet\Install-Package Decode.Hosting.Abstractions -Version 3.0.0
                    
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="Decode.Hosting.Abstractions" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Decode.Hosting.Abstractions" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Decode.Hosting.Abstractions" />
                    
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 Decode.Hosting.Abstractions --version 3.0.0
                    
#r "nuget: Decode.Hosting.Abstractions, 3.0.0"
                    
#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 Decode.Hosting.Abstractions@3.0.0
                    
#: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=Decode.Hosting.Abstractions&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Decode.Hosting.Abstractions&version=3.0.0
                    
Install as a Cake Tool

Decode.Hosting.Abstractions

Core contracts, options and context models for Decode background workers.

📦 Installation

dotnet add package Decode.Hosting.Abstractions

This package is contracts only — no dependencies beyond the framework. The worker implementation lives in Decode.Hosting; you normally reference that one, which brings this in transitively. Reference this package directly when a Domain or Application layer needs to see WorkerContext without depending on the hosting stack.

🛠️ Components

WorkerOptions

Configuration for a single worker.

public class WorkerOptions
{
    public TimeSpan Interval { get; set; } = TimeSpan.FromMinutes(1);
    public bool RunOnStartup { get; set; } = true;
    public TimeSpan ErrorBackoffDelay { get; set; } = TimeSpan.FromSeconds(5);
    public bool SuppressExceptions { get; set; } = true;
}
Option Default Meaning
Interval 1 minute Delay between cycles. Must be greater than zero, or the worker fails with a message naming this property.
RunOnStartup true Run one cycle immediately instead of waiting for the first interval to elapse.
ErrorBackoffDelay 5 seconds Extra wait after a failed cycle, applied only when SuppressExceptions is true.
SuppressExceptions true Keep the worker alive after an unhandled exception. When false, the exception propagates and faults the background service.

Interval is a delay between cycles, not a fixed schedule: the time a cycle spends running is added on top. A cycle that takes 20 seconds with a 1 minute interval runs every 80 seconds, not every 60.

WorkerContext

Passed to each cycle, identifying that cycle.

public class WorkerContext(Guid executionId, CancellationToken cancellationToken)
{
    public Guid ExecutionId { get; }
    public CancellationToken CancellationToken { get; }
}

ExecutionId is a fresh Guid per cycle. It is also written to the cycle's trace span as worker.execution_id and to the worker's log entries, so a span, a log line and a database record written during that cycle can all be correlated.

CancellationToken is the host's shutdown token. Pass it down to every async call you make inside a cycle so that shutdown is not delayed by work in flight.

📖 Usage

These types are only useful together with ScopedPeriodicWorker. See the Decode.Hosting readme for a complete worker.

using Decode.Hosting.Abstractions;

// A service that needs to know which cycle it is running in, without depending on the host.
public class OrderSweeper(IOrderRepository repository)
{
    public async Task SweepAsync(WorkerContext context)
    {
        await repository.MarkStaleAsync(context.ExecutionId, context.CancellationToken);
    }
}

📄 License

MIT License.

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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Decode.Hosting.Abstractions:

Package Downloads
Decode.Hosting

Resilient, scoped, and telemetry-instrumented background worker abstractions for the Decode library ecosystem.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 97 9/14/2026
2.1.0 113 9/13/2026
2.0.2 109 9/13/2026
2.0.1 112 9/13/2026
2.0.0 217 7/28/2026
1.0.3 152 7/22/2026