Samhammer.SingleExecuteHostedService
1.0.0
dotnet add package Samhammer.SingleExecuteHostedService --version 1.0.0
NuGet\Install-Package Samhammer.SingleExecuteHostedService -Version 1.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="Samhammer.SingleExecuteHostedService" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Samhammer.SingleExecuteHostedService --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Samhammer.SingleExecuteHostedService, 1.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.
// Install Samhammer.SingleExecuteHostedService as a Cake Addin #addin nuget:?package=Samhammer.SingleExecuteHostedService&version=1.0.0 // Install Samhammer.SingleExecuteHostedService as a Cake Tool #tool nuget:?package=Samhammer.SingleExecuteHostedService&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Samhammer.Samhammer.SingleExecuteHostedService
This package provides a single execute hosted service.
How to add this to your project:
- Reference this nuget package: https://www.nuget.org/packages/Samhammer.SingleExecuteHostedService/
How to use:
Implement a class that inherits from SingleExecuteHostedService.
public class MyHostedService : SingleExecuteHostedService<IMyService>
{
protected override TimeSpan ShutdownDelay => TimeSpan.FromSeconds(2);
public MyHostedService(ILogger<MyHostedService> logger, IServiceScopeFactory services, IHostApplicationLifetime applicationLifetime)
: base(logger, services, applicationLifetime)
{
}
protected override Task RunScoped(IMyService myService, CancellationToken stoppingToken)
{
myService.DoSomething();
return Task.CompletedTask;
}
}
Register the hosted service in startup:
public void ConfigureServices(IServiceCollection services)
{
services.AddHostedService<MyHostedService>()
}
Possible configurations:
- ShutdownDelay: Delay after executing a task in case a run is finished too fast since app could still be starting (default: 1)
Possible hook points:
- RunScoped: Execute your logic here (mandatory)
Note:
- "RunScoped" is running in it's ioc scope
Contribute
How to publish a nuget package
- Create a tag and let the github action do the publishing for you
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
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 |
---|---|---|
1.0.0 | 96 | 12/18/2024 |