![]() |
VOOZH | about |
dotnet add package Fusonic.Extensions.Hosting --version 10.1.0
NuGet\Install-Package Fusonic.Extensions.Hosting -Version 10.1.0
<PackageReference Include="Fusonic.Extensions.Hosting" Version="10.1.0" />
<PackageVersion Include="Fusonic.Extensions.Hosting" Version="10.1.0" />Directory.Packages.props
<PackageReference Include="Fusonic.Extensions.Hosting" />Project file
paket add Fusonic.Extensions.Hosting --version 10.1.0
#r "nuget: Fusonic.Extensions.Hosting, 10.1.0"
#:package Fusonic.Extensions.Hosting@10.1.0
#addin nuget:?package=Fusonic.Extensions.Hosting&version=10.1.0Install as a Cake Addin
#tool nuget:?package=Fusonic.Extensions.Hosting&version=10.1.0Install as a Cake Tool
If you have a service that should execute every once in a while, for example a sync, you can use TimedHostedService<> for triggering your service. You just have to care about your business logic, not about the hosting logic.
The TimedHostedService<> is a hosted service which executes a method in your service class, repeating after a specified interval.
It has the following behaviour:
Given the following Service:
public class HelloWorldService
{
public Task Run(CancellationToken cancellationToken)
{
Console.WriteLine("Hello world");
return LongRunningLogic(cancellationToken);
}
private Task LongRunningLogic(CancellationToken cancellationToken)
=> Task.Delay(10_000_000, cancellationToken);
}
When configuring your host you can register timed services in the AddSimpleInjector-part. There's an extension to the options AddTimedHostedService<TService>. It has a parameter for the configuration and one to call your method.
The configuration only consists of two options:
Interval: The interval in seconds in which your method should be executed. Defaults to 900 (15 minutes).WatchdogUri: The URI which should be called after a successfull run. Defaults to null.Example configuration:
var host = new HostBuilder()
.ConfigureHostConfiguration(/* ... */)
.ConfigureServices((hostContext, services) => {
// Some config
services.AddSimpleInjector(container, options =>
{
// Add HelloWorldService
// Configuration is in the appsettings-section "HelloWorld"
// We want to run our service method "Run" and we react to the provided cancellation token in there.
options.AddTimedHostedService<HelloWorldService>(cfg => hostContext.Configuration.Bind("HelloWorld", cfg), (svc, ct) => svc.Run(ct));
});
// Some more config
})
.Build()
The according configuration in the appettings for this example could look like the following. Note that all parameters are optional and the config could also be injected via EnvironmentVariables, depending on your HostConfiguration.
{
"HelloWorld": {
"Interval": 300,
"WatchdogUrl": "https://watchdog.fusonic.net/?projectId=12345"
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.0 | 138 | 3/18/2026 |
| 10.0.1 | 121 | 3/17/2026 |
| 10.0.0 | 264 | 11/25/2025 |
| 10.0.0-rc.2 | 187 | 11/24/2025 |
| 10.0.0-rc.1 | 153 | 9/12/2025 |
| 9.5.4 | 269 | 8/20/2025 |
| 9.5.3 | 322 | 3/28/2025 |
| 9.5.2 | 274 | 1/16/2025 |
| 9.5.0 | 274 | 10/4/2024 |
| 9.4.0 | 255 | 9/23/2024 |
| 9.3.1 | 285 | 9/11/2024 |
| 9.3.0 | 287 | 9/11/2024 |
| 9.2.0 | 269 | 8/8/2024 |
| 9.2.0-rc.3 | 130 | 8/7/2024 |
| 9.2.0-rc.2 | 130 | 8/5/2024 |
| 9.2.0-rc.1 | 118 | 8/1/2024 |
| 9.1.0 | 237 | 7/29/2024 |
| 9.0.0 | 274 | 7/17/2024 |
| 9.0.0-preview.2 | 128 | 6/13/2024 |
| 9.0.0-preview.1 | 138 | 4/5/2024 |