Bodoconsult.App.BackgroundService
1.0.4
dotnet add package Bodoconsult.App.BackgroundService --version 1.0.4
NuGet\Install-Package Bodoconsult.App.BackgroundService -Version 1.0.4
<PackageReference Include="Bodoconsult.App.BackgroundService" Version="1.0.4" />
<PackageVersion Include="Bodoconsult.App.BackgroundService" Version="1.0.4" />
<PackageReference Include="Bodoconsult.App.BackgroundService" />
paket add Bodoconsult.App.BackgroundService --version 1.0.4
#r "nuget: Bodoconsult.App.BackgroundService, 1.0.4"
#:package Bodoconsult.App.BackgroundService@1.0.4
#addin nuget:?package=Bodoconsult.App.BackgroundService&version=1.0.4
#tool nuget:?package=Bodoconsult.App.BackgroundService&version=1.0.4
What does the library
Bodoconsult.App is a library with basic functionality for multilayered monolithic applications like database based client server apps or windows services.
Bodoconsult.App.BackgroundServices enhances the functionality of Bodoconsult.App for Windows services NOT using GRPC.
It delivers the following main functionality:
- App start infrastructure for Windows services apps NOT using GRPC
How to use the library
The source code contains NUnit test classes the following source code is extracted from. The samples below show the most helpful use cases for the library.
App start infrastructure basics
See page app start infrastructure for details.
Using app start infrastructure for a Windows service
Here a sample from Program.cs Main() how to setup the console app in project WorkerService1 contained in this repo:
var globals = Globals.Instance;
globals.LoggingConfig.AddDefaultLoggerProviderConfiguratorsForBackgroundServiceApp();
// Set additional app start parameters as required
var param = globals.AppStartParameter;
param.AppName = "WorkerService1: Demo app";
param.SoftwareTeam = "Robert Leisner";
param.LogoRessourcePath = "WorkerService1.Resources.logo.jpg";
param.AppFolderName = "WorkerService1";
const string performanceToken = "--PERF";
if (args.Contains(performanceToken))
{
param.IsPerformanceLoggingActivated = true;
}
// Now start app buiding process
IAppBuilder builder = new WorkerService1AppBuilder(globals);
#if !DEBUG
AppDomain.CurrentDomain.UnhandledException += builder.CurrentDomainOnUnhandledException;
#endif
// Load basic app metadata
builder.LoadBasicSettings(typeof(Program));
// Process the config file
builder.ProcessConfiguration();
// Now load the globally needed settings
builder.LoadGlobalSettings();
// Write first log entry with default logger
Globals.Instance.Logger.LogInformation($"{param.AppName} {param.AppVersion} starts...");
Console.WriteLine("Logging started...");
// App is ready now for doing something
Console.WriteLine($"Connection string loaded: {param.DefaultConnectionString}");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine($"App name loaded: {param.AppName}");
Console.WriteLine($"App version loaded: {param.AppVersion}");
Console.WriteLine($"App path loaded: {param.AppPath}");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine($"Logging config: {ObjectHelper.GetObjectPropertiesAsString(Globals.Instance.LoggingConfig)}");
// Prepare the DI container package
builder.LoadDiContainerServiceProviderPackage();
builder.RegisterDiServices();
// builder.FinalizeDiContainerSetup(); Do call this method for a background service. It is too early for it
// Now finally start the app and wait
builder.StartApplication();
Environment.Exit(0);
About us
Bodoconsult http://www.bodoconsult.de is a Munich based software company from Germany.
Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- Bodoconsult.App (>= 1.0.4)
- Microsoft.Extensions.Hosting (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Bugfixes and improvements