![]() |
VOOZH | about |
dotnet add package Coject.BackgroundServices --version 1.0.0
NuGet\Install-Package Coject.BackgroundServices -Version 1.0.0
<PackageReference Include="Coject.BackgroundServices" Version="1.0.0" />
<PackageVersion Include="Coject.BackgroundServices" Version="1.0.0" />Directory.Packages.props
<PackageReference Include="Coject.BackgroundServices" />Project file
paket add Coject.BackgroundServices --version 1.0.0
#r "nuget: Coject.BackgroundServices, 1.0.0"
#:package Coject.BackgroundServices@1.0.0
#addin nuget:?package=Coject.BackgroundServices&version=1.0.0Install as a Cake Addin
#tool nuget:?package=Coject.BackgroundServices&version=1.0.0Install as a Cake Tool
Copyright (c) 2024 Akwad Arabia
A lightweight and easy-to-use background service library for ASP.NET Core applications. Manage SMS, Email, and custom background tasks with simple configuration.
✅ Easy Integration - One line of code to enable background services
✅ Configurable - Enable/disable services via appsettings.json
✅ Extensible - Add custom background tasks easily
✅ Logging Support - Built-in logging for all operations
✅ Scoped Services - Proper dependency injection with scoped lifetimes
dotnet add package Coject.BackgroundServices
Or via NuGet Package Manager:
Install-Package Coject.BackgroundServices
dotnet add package Coject.BackgroundServices
{
"BackgroundService": {
"EnabledServices": ["ServiceSMS", "ServiceMail"],
"IntervalSeconds": 10
}
}
using Coject.BackgroundServices.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Register your core dependencies
builder.Services.AddScoped<CoreModuleDB>();
builder.Services.AddScoped<ApiContext>();
// Add background services with one line
builder.Services.AddCojectBackgroundServices(builder.Configuration);
var app = builder.Build();
app.Run();
Your background services will start automatically and run based on the configured interval.
| Property | Type | Description | Default |
|---|---|---|---|
EnabledServices |
string[] |
Array of service names to enable | [] |
IntervalSeconds |
int |
Interval between executions in seconds | 60 |
ServiceSMS - SMS message processingServiceMail - Email message processingRun every 10 seconds:
{
"BackgroundService": {
"EnabledServices": ["ServiceSMS", "ServiceMail"],
"IntervalSeconds": 10
}
}
Enable only SMS:
{
"BackgroundService": {
"EnabledServices": ["ServiceSMS"],
"IntervalSeconds": 30
}
}
Disable all services:
{
"BackgroundService": {
"EnabledServices": [],
"IntervalSeconds": 60
}
}
using Coject.BackgroundServices.Interfaces;
public class CustomBackgroundTask : IBackgroundTask
{
private readonly ILogger<CustomBackgroundTask> _logger;
public string ServiceName => "ServiceCustom";
public CustomBackgroundTask(ILogger<CustomBackgroundTask> logger)
{
_logger = logger;
}
public async Task ExecuteAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Custom task executing...");
// Your logic here
}
}
builder.Services.AddCojectBackgroundServices(builder.Configuration);
builder.Services.AddBackgroundTask<CustomBackgroundTask>();
{
"BackgroundService": {
"EnabledServices": ["ServiceSMS", "ServiceMail", "ServiceCustom"],
"IntervalSeconds": 10
}
}
Your main project must register these dependencies before calling AddCojectBackgroundServices():
builder.Services.AddScoped<CoreModuleDB>();
builder.Services.AddScoped<ApiContext>();
The package uses ILogger for all logging. Configure your logging in appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Coject.BackgroundServices": "Debug"
}
}
}
MIT License - see LICENSE.txt for details
For issues, questions, or contributions, please visit:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. 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 |
|---|---|---|
| 1.0.0 | 229 | 11/6/2025 |
Initial release with SMS and Email background services support.