Imato.Services.RegularWorker 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Imato.Services.RegularWorker --version 1.0.0
                    
NuGet\Install-Package Imato.Services.RegularWorker -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="Imato.Services.RegularWorker" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Imato.Services.RegularWorker" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Imato.Services.RegularWorker" />
                    
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 Imato.Services.RegularWorker --version 1.0.0
                    
#r "nuget: Imato.Services.RegularWorker, 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.
#:package Imato.Services.RegularWorker@1.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=Imato.Services.RegularWorker&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Imato.Services.RegularWorker&version=1.0.0
                    
Install as a Cake Tool

Imato.Services.RegularWorker

Create long running services and workers
  1. Create new worker
// Worker.cs
using Imato.Services.RegularWorker;

public class Worker : RegularWorker
{

    public Worker(IServiceProvider provider) : base(provider)
    {
    }

    // Add same work in ExecuteAsync method
    public override async Task ExecuteAsync(CancellationToken token)
    {
        await SendHelloAsync();
    }
}
  1. Add worker to DI
// Program.cs
using Imato.Services.RegularWorker;

var appBuilder = Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddSingleton<IHostedService, Worker>();
    })
  1. Start all worker
// Program.cs
using Imato.Services.RegularWorker;

var app = appBuilder.Build();
app.StartServices();
await app.RunAsync();
Using Log table in MS SQL server

Add configuration for DbLogger: ConnectionString, Table and table Columns

// appsettings.json
{
  "ConnectionStrings": {
    "mssql": "Data Source=localhost;Initial Catalog=TestDb;Persist Security Info=True;User ID=test;Password=test;"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "DbLogger": {
      "Options": {
        "ConnectionString": "Data Source=localhost;Initial Catalog=TestDb;Persist Security Info=True;User ID=test;Password=test;",
        "Table": "dbo.Logs",
        "Columns": "[Date], [User], [Level], [Source], [Message], [Server]"
      }
    }
  }
}

Add logger in DI config

// Program.cs
using Imato.Services.RegularWorker;

var appBuilder = Host.CreateDefaultBuilder(args)
    .ConfigureDbLogger();
    .ConfigureServices(services =>
        {
            services.AddSingleton<IHostedService, LogWorker>();
        });

// Start LogWorker and other workers
var app = appBuilder.Build();
app.StartServices();
await app.RunAsync();
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  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 was computed.  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

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
3.3.0 111 7/18/2025
3.2.2 194 3/19/2025
3.2.1 149 12/5/2024
3.2.0 141 10/25/2024
3.1.1 135 10/15/2024
3.0.2 174 8/29/2024
3.0.0 161 6/21/2024
2.18.0 148 5/15/2024
2.17.4 196 3/6/2024
2.17.3 221 1/25/2024
2.17.2 151 1/24/2024
2.17.1 152 1/23/2024
2.17.0 181 1/17/2024
2.16.9 221 12/28/2023
2.16.8 186 12/28/2023
2.16.6 184 12/28/2023
2.16.5 166 12/28/2023
2.16.4 186 12/27/2023
2.16.0 159 12/20/2023
2.15.0 159 12/19/2023
2.14.0 168 12/18/2023
2.13.0 207 11/28/2023
2.12.2 214 10/18/2023
2.12.1 182 10/18/2023
2.12.0 172 9/22/2023
2.11.0 192 9/15/2023
2.10.0 239 6/7/2023
2.9.2 232 6/1/2023
2.9.1 221 6/1/2023
2.9.0 254 6/1/2023
2.6.0 207 5/22/2023
2.5.2 328 3/23/2023
2.5.1 318 2/27/2023
2.5.0 353 1/12/2023
2.4.2 414 12/26/2022
2.4.0 391 12/19/2022
2.2.1 399 12/12/2022
2.1.1 409 11/23/2022
2.1.0 407 11/23/2022
2.0.0 479 9/23/2022
1.1.0 517 8/17/2022
1.0.0 478 8/10/2022

Ready to use