VOOZH about

URL: https://www.nuget.org/packages/Coject.BackgroundServices/

⇱ NuGet Gallery | Coject.BackgroundServices 1.0.0




👁 Image
Coject.BackgroundServices 1.0.0

dotnet add package Coject.BackgroundServices --version 1.0.0
 
 
NuGet\Install-Package Coject.BackgroundServices -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="Coject.BackgroundServices" Version="1.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Coject.BackgroundServices" Version="1.0.0" />
 
Directory.Packages.props
<PackageReference Include="Coject.BackgroundServices" />
 
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 Coject.BackgroundServices --version 1.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Coject.BackgroundServices, 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 Coject.BackgroundServices@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=Coject.BackgroundServices&version=1.0.0
 
Install as a Cake Addin
#tool nuget:?package=Coject.BackgroundServices&version=1.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Copyright (c) 2024 Akwad Arabia

CojectCore.BackgroundServices

A lightweight and easy-to-use background service library for ASP.NET Core applications. Manage SMS, Email, and custom background tasks with simple configuration.

Features

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

Installation

dotnet add package Coject.BackgroundServices

Or via NuGet Package Manager:

Install-Package Coject.BackgroundServices

Quick Start

1. Install the package

dotnet add package Coject.BackgroundServices

2. Configure appsettings.json

{
 "BackgroundService": {
 "EnabledServices": ["ServiceSMS", "ServiceMail"],
 "IntervalSeconds": 10
 }
}

3. Register in Program.cs

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();

4. Done! 🎉

Your background services will start automatically and run based on the configured interval.

Configuration

appsettings.json

Property Type Description Default
EnabledServices string[] Array of service names to enable []
IntervalSeconds int Interval between executions in seconds 60

Available Services

  • ServiceSMS - SMS message processing
  • ServiceMail - Email message processing

Examples

Run every 10 seconds:

{
 "BackgroundService": {
 "EnabledServices": ["ServiceSMS", "ServiceMail"],
 "IntervalSeconds": 10
 }
}

Enable only SMS:

{
 "BackgroundService": {
 "EnabledServices": ["ServiceSMS"],
 "IntervalSeconds": 30
 }
}

Disable all services:

{
 "BackgroundService": {
 "EnabledServices": [],
 "IntervalSeconds": 60
 }
}

Adding Custom Background Tasks

1. Create your task class

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
 }
}

2. Register it

builder.Services.AddCojectBackgroundServices(builder.Configuration);
builder.Services.AddBackgroundTask<CustomBackgroundTask>();

3. Enable in appsettings.json

{
 "BackgroundService": {
 "EnabledServices": ["ServiceSMS", "ServiceMail", "ServiceCustom"],
 "IntervalSeconds": 10
 }
}

Requirements

  • .NET 6.0 or higher
  • ASP.NET Core

Dependencies

Your main project must register these dependencies before calling AddCojectBackgroundServices():

builder.Services.AddScoped<CoreModuleDB>();
builder.Services.AddScoped<ApiContext>();

Logging

The package uses ILogger for all logging. Configure your logging in appsettings.json:

{
 "Logging": {
 "LogLevel": {
 "Default": "Information",
 "Coject.BackgroundServices": "Debug"
 }
 }
}

License

MIT License - see LICENSE.txt for details

Support

For issues, questions, or contributions, please visit:

Changelog

Version 1.0.0

  • Initial release
  • SMS background service
  • Email background service
  • Configurable intervals
  • Enable/disable services via configuration
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. 
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
1.0.0 229 11/6/2025

Initial release with SMS and Email background services support.