add Support for Background Services ...

This commit is contained in:
2026-08-19 12:33:57 +03:30
parent 32dd5dd3c1
commit 4697937709
4 changed files with 359 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
using Microsoft.Extensions.DependencyInjection;
using xCommons.Providers;
namespace xCommons.Extensions
{
public static class BackgroundServiceExtensions
{
/// <summary>
/// Register Background Services ...
/// </summary>
/// <typeparam name="TService"></typeparam>
/// <param name="source"></param>
/// <param name="service"></param>
public static void AddXBackgroundService<TService>(
this IServiceCollection source,
TService service
)
where TService : XBackgroundService
{
//
source.AddSingleton(service);
source.AddHostedService<TService>();
}
}
}