diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/ServiceCollectionHostedServiceExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/ServiceCollectionHostedServiceExtensions.cs index 67ea8b13cbd58c..6e57df438308b3 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/ServiceCollectionHostedServiceExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/ServiceCollectionHostedServiceExtensions.cs @@ -16,6 +16,19 @@ public static class ServiceCollectionHostedServiceExtensions /// /// Add an registration for the given type. /// + /// + /// Note that this creates registration for specifically. Not for the actual THostedService type. + /// If you want to register the actual type, you must do so separately. + /// + /// + /// + /// The following code shows how to register a hosted service while also registering the actual THostedService type. + /// + /// + /// services.AddSingleton<SomeService>(); + /// services.AddHostedService(sp => sp.GetRequiredService<SomeService>()); + /// + /// /// An to register. /// The to register with. /// The original . @@ -30,6 +43,19 @@ public static class ServiceCollectionHostedServiceExtensions /// /// Add an registration for the given type. /// + /// + /// Note that this creates registration for specifically. Not for the actual THostedService type. + /// If you want to register the actual type, you must do so separately. + /// + /// + /// + /// The following code shows how to register a hosted service while also registering the actual THostedService type. + /// + /// + /// services.AddSingleton<SomeService>(implementationFactory); + /// services.AddHostedService(sp => sp.GetRequiredService<SomeService>()); + /// + /// /// An to register. /// The to register with. /// A factory to create new instances of the service implementation.