ServiceCollectionHostedServiceExtensions.AddHostedService Метод

Определение

Перегрузки

AddHostedService<THostedService>(IServiceCollection)

Добавьте регистрацию IHostedService для заданного типа.Add an IHostedService registration for the given type.

AddHostedService<THostedService>(IServiceCollection, Func<IServiceProvider,THostedService>)

Добавьте регистрацию IHostedService для заданного типа.Add an IHostedService registration for the given type.

AddHostedService<THostedService>(IServiceCollection)

Добавьте регистрацию IHostedService для заданного типа.Add an IHostedService registration for the given type.

public:
generic <typename THostedService>
 where THostedService : class, Microsoft::Extensions::Hosting::IHostedService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddHostedService(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddHostedService<THostedService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where THostedService : class, Microsoft.Extensions.Hosting.IHostedService;
static member AddHostedService : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'HostedService : null and 'HostedService :> Microsoft.Extensions.Hosting.IHostedService)
<Extension()>
Public Function AddHostedService(Of THostedService As {Class, IHostedService}) (services As IServiceCollection) As IServiceCollection

Параметры типа

THostedService

IHostedServiceРегистрируемый объект.An IHostedService to register.

Параметры

services
IServiceCollection

IServiceCollection, используемый для регистрации.The IServiceCollection to register with.

Возвращаемое значение

IServiceCollection

Исходный объект IServiceCollection.The original IServiceCollection.

Применяется к

AddHostedService<THostedService>(IServiceCollection, Func<IServiceProvider,THostedService>)

Добавьте регистрацию IHostedService для заданного типа.Add an IHostedService registration for the given type.

public:
generic <typename THostedService>
 where THostedService : class, Microsoft::Extensions::Hosting::IHostedService[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddHostedService(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<IServiceProvider ^, THostedService> ^ implementationFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddHostedService<THostedService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<IServiceProvider,THostedService> implementationFactory) where THostedService : class, Microsoft.Extensions.Hosting.IHostedService;
static member AddHostedService : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<IServiceProvider, 'HostedService (requires 'HostedService : null and 'HostedService :> Microsoft.Extensions.Hosting.IHostedService)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'HostedService : null and 'HostedService :> Microsoft.Extensions.Hosting.IHostedService)
<Extension()>
Public Function AddHostedService(Of THostedService As {Class, IHostedService}) (services As IServiceCollection, implementationFactory As Func(Of IServiceProvider, THostedService)) As IServiceCollection

Параметры типа

THostedService

IHostedServiceРегистрируемый объект.An IHostedService to register.

Параметры

services
IServiceCollection

IServiceCollection, используемый для регистрации.The IServiceCollection to register with.

implementationFactory
Func<IServiceProvider,THostedService>

Фабрика для создания экземпляров реализации службы.A factory to create new instances of the service implementation.

Возвращаемое значение

IServiceCollection

Исходный объект IServiceCollection.The original IServiceCollection.

Применяется к