1 interface inheriting from IHostedService
Microsoft.Extensions.Hosting.Abstractions (1)
IHostedLifecycleService.cs (1)
14public interface IHostedLifecycleService : IHostedService
16 implementations of IHostedService
aspire (1)
Telemetry\AspireCliTelemetry.cs (1)
16internal sealed class AspireCliTelemetry : AspireTelemetryBase, IHostedService
Aspire.Dashboard (2)
ServiceClient\DashboardDataSourceInitializer.cs (1)
9ILogger<DashboardDataSourceInitializer> logger) : IHostedService, IDisposable
Telemetry\DashboardTelemetryManager.cs (1)
14internal sealed class DashboardTelemetryManager : IHostedService, IAsyncDisposable
Aspire.Hosting (2)
ApplicationModel\TerminalServiceHost.cs (1)
13internal sealed class TerminalServiceHost(TerminalService terminalService) : IHostedService
Dashboard\DashboardServiceHost.cs (1)
28internal sealed class DashboardServiceHost : IHostedService
Aspire.Hosting.Foundry (1)
FoundryLocalService.cs (1)
750internal sealed class FoundryLocalLifecycleService : IHostedService, IAsyncDisposable
Aspire.Hosting.RemoteHost (1)
Language\IntegrationHostLauncher.cs (1)
16internal sealed class IntegrationHostLauncher : IHostedService, IAsyncDisposable
Aspire.Hosting.Testing.Tests (1)
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
103internal sealed class DcpLogForwarder : IHostedService
Aspire.Hosting.TestUtilities (1)
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
103internal sealed class DcpLogForwarder : IHostedService
Microsoft.AspNetCore.Components.Testing (1)
Infrastructure\ReadinessNotificationService.cs (1)
13internal class ReadinessNotificationService : IHostedService
Microsoft.AspNetCore.DataProtection (1)
Internal\DataProtectionHostedService.cs (1)
14internal sealed class DataProtectionHostedService : IHostedService
Microsoft.AspNetCore.Hosting (1)
GenericHost\GenericWebHostService.cs (1)
17internal sealed partial class GenericWebHostService : IHostedService
Microsoft.Extensions.DependencyInjection.AutoActivation (1)
AutoActivationHostedService.cs (1)
13internal sealed class AutoActivationHostedService : IHostedService
Microsoft.Extensions.Diagnostics.HealthChecks (1)
HealthCheckPublisherHostedService.cs (1)
19internal sealed partial class HealthCheckPublisherHostedService : IHostedService
Microsoft.Extensions.Hosting.Abstractions (1)
BackgroundService.cs (1)
13public abstract class BackgroundService : IHostedService, IDisposable
Nats.Backend (1)
Program.cs (1)
16public class AppEventsBackendService(INatsClient nats, ILogger<AppEventsBackendService> logger) : IHostedService
84 references to IHostedService
Aspire.Cli.Tests (1)
Utils\CliTestHelper.cs (1)
191services.AddSingleton<IHostedService>(sp => sp.GetRequiredService<NuGetPackagePrefetcher>());
Aspire.Dashboard.Tests (1)
Telemetry\DashboardTelemetryManagerTests.cs (1)
131Assert.Same(manager, Assert.Single(services.GetServices<IHostedService>()));
Aspire.Hosting (6)
Dashboard\DashboardServiceHost.cs (2)
261async Task IHostedService.StartAsync(CancellationToken cancellationToken) 279async Task IHostedService.StopAsync(CancellationToken cancellationToken)
DistributedApplication.cs (4)
511/// triggered and all <see cref="IHostedService" /> instances are stopped. 530/// of <see cref="IHostedService"/> instances which are added to the dependency injection 589/// <see cref="IHostedService"/> instances are stopped. 605/// of <see cref="IHostedService"/> instances which are added to the dependency injection
Aspire.Hosting.Azure.Tests (1)
FoundryExtensionsTests.cs (1)
97Assert.Contains(app.Services.GetServices<global::Microsoft.Extensions.Hosting.IHostedService>(), service => service is FoundryLocalLifecycleService);
Aspire.Hosting.Foundry (1)
FoundryExtensions.cs (1)
232builder.ApplicationBuilder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, FoundryLocalLifecycleService>());
Aspire.Hosting.Testing.Tests (2)
ResourceLoggerForwarderServiceTests.cs (1)
23sd.ServiceType == typeof(IHostedService)
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
78services.AddSingleton<IHostedService>(sp => new DcpLogForwarder(testOutputHelper, uniqueFolder));
Aspire.Hosting.Tests (6)
DistributedApplicationTests.cs (4)
1513await ((IHostedService)dashboardServiceHost).StartAsync(CancellationToken.None); 1522await ((IHostedService)dashboardServiceHost).StopAsync(CancellationToken.None); 1543await ((IHostedService)dashboardServiceHost).StartAsync(CancellationToken.None); 1557await ((IHostedService)dashboardServiceHost).StopAsync(CancellationToken.None);
Terminals\TerminalServiceTests.cs (2)
788descriptor.ServiceType == typeof(IHostedService) && 793Assert.Single(builder.Services, descriptor => descriptor.ServiceType == typeof(IHostedService));
Aspire.Hosting.TestUtilities (1)
tests\Shared\DistributedApplicationTestingBuilderExtensions.cs (1)
78services.AddSingleton<IHostedService>(sp => new DcpLogForwarder(testOutputHelper, uniqueFolder));
Microsoft.AspNetCore (1)
BootstrapHostBuilder.cs (1)
109if (descriptor.ServiceType == typeof(IHostedService))
Microsoft.AspNetCore.Components.WebAssembly (4)
Hosting\HostedServiceExecutor.cs (4)
11private readonly IEnumerable<IHostedService> _services; 14public HostedServiceExecutor(IEnumerable<IHostedService> services, ILogger<HostedServiceExecutor> logger) 22foreach (var service in _services) 32foreach (var service in _services)
Microsoft.AspNetCore.DataProtection (1)
DataProtectionServiceCollectionExtensions.cs (1)
77services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, DataProtectionHostedService>());
Microsoft.AspNetCore.Hosting (4)
Internal\HostedServiceExecutor.cs (4)
10private readonly IEnumerable<IHostedService> _services; 12public HostedServiceExecutor(IEnumerable<IHostedService> services) 19foreach (var service in _services) 29foreach (var service in _services)
Microsoft.Extensions.Diagnostics.HealthChecks (1)
DependencyInjection\HealthCheckServiceCollectionExtensions.cs (1)
29services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, HealthCheckPublisherHostedService>());
Microsoft.Extensions.Diagnostics.Probes (1)
TcpEndpointProbesExtensions.cs (1)
49_ = services.AddSingleton<IHostedService>(provider =>
Microsoft.Extensions.Diagnostics.Probes.Tests (10)
KubernetesProbesExtensionsTests.cs (3)
36var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService"); 80var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService"); 108var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService");
TcpEndpointProbesExtensionsTests.cs (7)
36var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 55var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 73var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 92var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 118var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 143var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 164var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService);
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
ResourceMonitorBuilder.cs (1)
20services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, ResourceMonitorService>(static sp => sp.GetRequiredService<ResourceMonitorService>()));
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (4)
ResourceMonitoringExtensionsTests.cs (4)
89var allHostedServices = provider.GetServices<IHostedService>(); 90var trackerService = allHostedServices.Single(s => s is ResourceMonitorService); 214var backgrounds = host.Services.GetServices<IHostedService>().Where(x => x is ResourceMonitorService).ToArray(); 217var background = Assert.Single(backgrounds);
Microsoft.Extensions.Hosting (12)
HostOptions.cs (4)
37/// Gets or sets a value that indicates if the <see cref="IHost"/> will start registered instances of <see cref="IHostedService"/> concurrently or sequentially. 40/// <see langword="true"/> if the <see cref="IHost"/> will start registered instances of <see cref="IHostedService"/> concurrently; <see langword="false"/> if the <see cref="IHost"/> will start registered instances sequentially. The default is <see langword="false"/> . 45/// Gets or sets a value that indicates if the <see cref="IHost"/> will stop registered instances of <see cref="IHostedService"/> concurrently or sequentially. 48/// <see langword="true"/> if the <see cref="IHost"/> will stop registered instances of <see cref="IHostedService"/> concurrently; <see langword="false"/> if the <see cref="IHost"/> will stop registered instances sequentially. The default is <see langword="false"/> .
Internal\Host.cs (8)
29private IEnumerable<IHostedService>? _hostedServices; 184_hostedServices ??= Services.GetRequiredService<IEnumerable<IHostedService>>(); 344IEnumerable<IHostedService> reversedServices = _hostedServices.Reverse(); 524private static List<IHostedLifecycleService>? GetHostLifecycles(IEnumerable<IHostedService> hostedServices) 528foreach (IHostedService hostedService in hostedServices) 588public List<IHostedService> HostedServices => new List<IHostedService>(host._hostedServices ??= host.Services.GetRequiredService<IEnumerable<IHostedService>>());
Microsoft.Extensions.Hosting.Abstractions (20)
BackgroundService.cs (3)
11/// Base class for implementing a long running <see cref="IHostedService"/>. 27/// This method is called when the <see cref="IHostedService"/> starts. The implementation should return a task that represents 30/// <param name="stoppingToken">Triggered when <see cref="IHostedService.StopAsync(CancellationToken)"/> is called.</param>
IHost.cs (1)
21/// Starts the <see cref="IHostedService" /> objects configured for the program.
IHostedLifecycleService.cs (6)
11/// <see cref="IHostedService.StartAsync(CancellationToken)"/> and 12/// <see cref="IHostedService.StopAsync(CancellationToken)"/>. 17/// Triggered before <see cref="IHostedService.StartAsync(CancellationToken)"/>. 24/// Triggered after <see cref="IHostedService.StartAsync(CancellationToken)"/>. 31/// Triggered before <see cref="IHostedService.StopAsync(CancellationToken)"/>. 38/// Triggered after <see cref="IHostedService.StopAsync(CancellationToken)"/>.
ServiceCollectionHostedServiceExtensions.cs (10)
17/// Add an <see cref="IHostedService"/> registration for the given type. 20/// Note that this creates registration for <see cref="IHostedService"/> specifically. Not for the actual <c>THostedService</c> type. 32/// <typeparam name="THostedService">An <see cref="IHostedService"/> to register.</typeparam> 36where THostedService : class, IHostedService 38services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, THostedService>()); 44/// Add an <see cref="IHostedService"/> registration for the given type. 47/// Note that this creates registration for <see cref="IHostedService"/> specifically. Not for the actual <c>THostedService</c> type. 59/// <typeparam name="THostedService">An <see cref="IHostedService"/> to register.</typeparam> 64where THostedService : class, IHostedService 66services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService>(implementationFactory));
Microsoft.Extensions.Hosting.Testing (2)
FakeHostingExtensions.cs (1)
32public static async Task StartAndStopAsync(this IHostedService service, CancellationToken cancellationToken = default)
HostTerminatorService.cs (1)
40/// <param name="stoppingToken">Triggered when <see cref="IHostedService.StopAsync(CancellationToken)"/> is called.</param>
Microsoft.Extensions.Hosting.Testing.Tests (3)
FakeHostBuilderTests.cs (1)
39Assert.Contains(hostBuilderServices.GetServices<IHostedService>(), x => x is HostTerminatorService);
HostingFakesExtensionsTests.cs (2)
21var exception = await Record.ExceptionAsync(() => ((IHostedService)null!).StartAndStopAsync()); 30var serviceMock = new Mock<IHostedService>(MockBehavior.Strict);
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Logging\HttpClientLoggingExtensionsTest.cs (1)
545.GetRequiredService<IHostedService>()