# ResourceNotificationService Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ResourceNotificationService](/reference/api/csharp/aspire.hosting/resourcenotificationservice.md)
- Kind: `Constructors`
- Members: `2`

A service that allows publishing and subscribing to changes in the state of a resource.

## ResourceNotificationService(ILogger<ResourceNotificationService>, IHostApplicationLifetime)

> **Obsolete:** ResourceNotificationService now requires an IServiceProvider and ResourceLoggerService.
Use the constructor that accepts an ILogger<ResourceNotificationService>, IHostApplicationLifetime, IServiceProvider and ResourceLoggerService.
This constructor will be removed in the next major version of Aspire.

- Name: `Constructor(ILogger<ResourceNotificationService>, IHostApplicationLifetime)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs#L25-L511)

Creates a new instance of [ResourceNotificationService](/reference/api/csharp/aspire.hosting/resourcenotificationservice.md).

```csharp
public class ResourceNotificationService
{
    public ResourceNotificationService(
        ILogger<ResourceNotificationService> logger,
        IHostApplicationLifetime hostApplicationLifetime)
    {
        // ...
    }
}
```

## Parameters

- `logger` (`ILogger<ResourceNotificationService>`)
  The logger.
- `hostApplicationLifetime` (`IHostApplicationLifetime`)
  The host application lifetime.

## Remarks

Obsolete. Use the constructor that accepts an `Logging.ILogger`1`, `Hosting.IHostApplicationLifetime` and `IServiceProvider`. This constructor will be removed in the next major version of Aspire.

## ResourceNotificationService(ILogger<ResourceNotificationService>, IHostApplicationLifetime, IServiceProvider, ResourceLoggerService)

- Name: `Constructor(ILogger<ResourceNotificationService>, IHostApplicationLifetime, IServiceProvider, ResourceLoggerService)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs#L25-L511)

Creates a new instance of [ResourceNotificationService](/reference/api/csharp/aspire.hosting/resourcenotificationservice.md).

```csharp
public class ResourceNotificationService
{
    public ResourceNotificationService(
        ILogger<ResourceNotificationService> logger,
        IHostApplicationLifetime hostApplicationLifetime,
        IServiceProvider serviceProvider,
        ResourceLoggerService resourceLoggerService)
    {
        // ...
    }
}
```

## Parameters

- `logger` (`ILogger<ResourceNotificationService>`)
  The logger.
- `hostApplicationLifetime` (`IHostApplicationLifetime`)
  The host application lifetime.
- `serviceProvider` (`IServiceProvider`)
  The service provider.
- `resourceLoggerService` ([ResourceLoggerService](/reference/api/csharp/aspire.hosting/resourceloggerservice.md))
  The resource logger service.
