ServiceCollectionHostedServiceExtensions.AddHostedService Metoda

Definicja

Przeciążenia

AddHostedService<THostedService>(IServiceCollection)

Dodaj rejestrację IHostedService dla danego typu.

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

Dodaj rejestrację IHostedService dla danego typu.

AddHostedService<THostedService>(IServiceCollection)

Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs

Dodaj rejestrację IHostedService dla danego typu.

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

Parametry typu

THostedService

Obiekt do zarejestrowania IHostedService .

Parametry

services
IServiceCollection

Element do zarejestrowania IServiceCollection .

Zwraca

Oryginalny element IServiceCollection.

Uwagi

Uwaga

Ta metoda nie powinna być wywoływana wiele razy dla tej samej klasy. Spowoduje to zarejestrowanie tylko pierwszej podanej usługi hostowanej. Aby dodać wiele usług HostedServices, należy użyć dla AddSingleton<TService>(IServiceCollection) każdej implementacji jawnie IHostedService .

Dotyczy

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

Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs
Źródło:
ServiceCollectionHostedServiceExtensions.cs

Dodaj rejestrację IHostedService dla danego typu.

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

Parametry typu

THostedService

Obiekt do zarejestrowania IHostedService .

Parametry

services
IServiceCollection

Element do zarejestrowania IServiceCollection .

implementationFactory
Func<IServiceProvider,THostedService>

Fabryka do tworzenia nowych wystąpień implementacji usługi.

Zwraca

Oryginalny element IServiceCollection.

Uwagi

Uwaga

Ta metoda nie powinna być wywoływana wiele razy dla tej samej klasy. Spowoduje to zarejestrowanie tylko pierwszej podanej usługi hostowanej. Aby dodać wiele usług HostedServices, należy użyć dla AddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>) każdej implementacji jawnie IHostedService .

Dotyczy