add Support for Background Services ...
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user