ServiceCollectionHostedServiceExtensions.AddHostedService Yöntem

Tanım

Aşırı Yüklemeler

AddHostedService<THostedService>(IServiceCollection)

Verilen tür için bir IHostedService kayıt ekleyin.

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

Verilen tür için bir IHostedService kayıt ekleyin.

AddHostedService<THostedService>(IServiceCollection)

Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs

Verilen tür için bir IHostedService kayıt ekleyin.

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

Tür Parametreleri

THostedService

Kayıt için bir IHostedService .

Parametreler

services
IServiceCollection

ile IServiceCollection kaydedilecek.

Döndürülenler

Özgün IServiceCollection.

Açıklamalar

Not

Aynı sınıf için bu yöntemi birden çok kez çağırmamalısınız. Bunu yaptığınızda yalnızca sağladığınız ilk HostedService kaydedilecektir. Birden çok HostedService eklemek için, uygulamasının her uygulaması IHostedService için açıkça kullanınAddSingleton<TService>(IServiceCollection).

Şunlara uygulanır

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

Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs
Kaynak:
ServiceCollectionHostedServiceExtensions.cs

Verilen tür için bir IHostedService kayıt ekleyin.

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

Tür Parametreleri

THostedService

Kayıt için bir IHostedService .

Parametreler

services
IServiceCollection

ile IServiceCollection kaydedilecek.

implementationFactory
Func<IServiceProvider,THostedService>

Hizmet uygulamasının yeni örneklerini oluşturmak için bir fabrika.

Döndürülenler

Özgün IServiceCollection.

Açıklamalar

Not

Aynı sınıf için bu yöntemi birden çok kez çağırmamalısınız. Bunu yaptığınızda yalnızca sağladığınız ilk HostedService kaydedilecektir. Birden çok HostedService eklemek için, uygulamasının her uygulaması IHostedService için açıkça kullanınAddSingleton<TService>(IServiceCollection, Func<IServiceProvider,TService>).

Şunlara uygulanır