Bsft.Hosting.StartGates 2.3.0

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

Bsft.Hosting.StartGates

Start gates for hosted background loops: register a precondition once, and every loop registered as gated starts only after it has opened. The loops themselves know nothing about gates.

Install

dotnet add package Bsft.Hosting.StartGates

Requires Bsft.Core (the gate contract) and the generic host's abstractions, and nothing else.

Register a gate

internal sealed class SchemaGate : IHostedWorkStartGate
{
    public Task WaitAsync(CancellationToken cancellationToken) => /* completes once the schema is current */;
}

services.AddBsftHostedWorkStartGate<SchemaGate>();
// or, for a gate the host also registers under its own type:
services.AddBsftHostedWorkStartGate(sp => sp.GetRequiredService<SchemaGate>());

Several gates may be registered; a loop waits for all of them, in registration order. A gate that also implements IHostedWorkStartGateOverdueSignal is what the opt-in hosted-work-start-gates health check of Bsft.Hosting reports.

Register a loop as gated

services.AddBsftGatedHostedService<MyLoop>();
services.AddBsftGatedHostedService(sp => new MyLoop(sp.GetRequiredService<IWork>()));

The replacement for AddHostedService for a loop that must not run before the host's preconditions hold. The framework's own dispatchers, sweepers and workers are registered this way. Which gates exist is decided when the host starts, so the order of the two registrations does not matter.

  • With no gate registered the host gets the loop itself: nothing differs from AddHostedService.
  • With gates the host gets a wrapper whose start returns at once and which starts the loop after the gates. It is a BackgroundService, so HostOptions.ServicesStartConcurrently and BackgroundServiceExceptionBehavior apply to it as to any loop; a gate that throws faults it like a loop that fails.
  • A stop while a gate is pending ends the wrapper cleanly and does not stop the loop, which never started.

Hosted services that react to events or run once at start (subscribers, validators, bootstrappers) stay on AddHostedService and are never held back.

Documentation

Topic page: docs/hosting.md.

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 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.  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 (10)

Showing the top 5 NuGet packages that depend on Bsft.Hosting.StartGates:

Package Downloads
Bsft.Retention

BSFT Framework retention: a hosted sweeper that drives one bounded purge pass per set of records a package owns

Bsft.EventAggregator.Saga

BSFT Framework saga/flow engine on top of IEventAggregator

Bsft.Outbox

BSFT Framework outbox kernel: the drain pass, the retry schedule and the retirement policy every transactional outbox in a host shares, and the optional hosted drain worker.

Bsft.Messaging

BSFT Framework messaging: in-memory message bus, integration event staging and the transactional outbox dispatcher.

Bsft.Scheduling

BSFT Framework job scheduling: recurring (cron/interval) and delayed background jobs on a leased, durable dispatcher

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 161 11/27/2026