ServiceCollectionHostedServiceExtensions.AddHostedService 메서드

정의

오버로드

AddHostedService<THostedService>(IServiceCollection)

지정된 형식에 대한 IHostedService 등록을 추가합니다.

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

지정된 형식에 대한 IHostedService 등록을 추가합니다.

AddHostedService<THostedService>(IServiceCollection)

Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs

지정된 형식에 대한 IHostedService 등록을 추가합니다.

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 .

매개 변수

services
IServiceCollection

등록할 IServiceCollection입니다.

반환

원래 IServiceCollection입니다.

설명

참고

동일한 클래스에 대해 이 메서드를 여러 번 호출하면 안 됩니다. 이렇게 하면 제공하는 첫 번째 HostedService만 등록됩니다. 여러 HostedServices를 추가하려면 의 IHostedService 각 구현에 를 명시적으로 사용합니다AddSingleton<TService>(IServiceCollection).

적용 대상

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

Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs
Source:
ServiceCollectionHostedServiceExtensions.cs

지정된 형식에 대한 IHostedService 등록을 추가합니다.

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 .

매개 변수

services
IServiceCollection

등록할 IServiceCollection입니다.

implementationFactory
Func<IServiceProvider,THostedService>

서비스 구현의 새 인스턴스를 만들 팩터리입니다.

반환

원래 IServiceCollection입니다.

설명

참고

동일한 클래스에 대해 이 메서드를 여러 번 호출하면 안 됩니다. 이렇게 하면 제공하는 첫 번째 HostedService만 등록됩니다. 여러 HostedServices를 추가하려면 의 IHostedService 각 구현에 를 명시적으로 사용합니다AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>).

적용 대상