# ResourceNotificationService

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs)
- Implements: `IDisposable`

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

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public class ResourceNotificationService
    : System.IDisposable
{
    // ...
}
```

## Constructors

- [ResourceNotificationService(ILogger<ResourceNotificationService>, IHostApplicationLifetime)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/constructors.md#constructor-ilogger-resourcenotificationservice-ihostapplicationlifetime) `obsolete` -- Creates a new instance of [ResourceNotificationService](/reference/api/csharp/aspire.hosting/resourcenotificationservice.md).
- [ResourceNotificationService(ILogger<ResourceNotificationService>, IHostApplicationLifetime, IServiceProvider, ResourceLoggerService)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/constructors.md#constructor-ilogger-resourcenotificationservice-ihostapplicationlifetime-iserviceprovider-resourceloggerservice) -- Creates a new instance of [ResourceNotificationService](/reference/api/csharp/aspire.hosting/resourcenotificationservice.md).

## Methods

- [Dispose](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#dispose) -- Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- [PublishUpdateAsync(IResource, string, Func<CustomResourceSnapshot, CustomResourceSnapshot>)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#publishupdateasync-iresource-string-func-customresourcesnapshot-customresourcesnapshot) : `Task` -- Updates the snapshot of the [CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md) for a resource.
- [PublishUpdateAsync(IResource, Func<CustomResourceSnapshot, CustomResourceSnapshot>)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#publishupdateasync-iresource-func-customresourcesnapshot-customresourcesnapshot) : `Task` -- Updates the snapshot of the [CustomResourceSnapshot](/reference/api/csharp/aspire.hosting/customresourcesnapshot.md) for a resource.
- [TryGetCurrentState(string, ResourceEvent?)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#trygetcurrentstate-string-resourceevent) : `bool` -- Attempts to retrieve the current state of a resource by resourceId.
- [WaitForDependenciesAsync(IResource, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitfordependenciesasync-iresource-cancellationtoken) : `Task` -- Waits for all dependencies of the resource to be ready.
- [WaitForResourceAsync(string, string?, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitforresourceasync-string-string-cancellationtoken) : `Task` -- Waits for a resource to reach the specified state. See [KnownResourceStates](/reference/api/csharp/aspire.hosting/knownresourcestates.md) for common states.
- [WaitForResourceAsync(string, IEnumerable<string>, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitforresourceasync-string-ienumerable-string-cancellationtoken) : `Task<string>` -- Waits for a resource to reach one of the specified states. See [KnownResourceStates](/reference/api/csharp/aspire.hosting/knownresourcestates.md) for common states.
- [WaitForResourceAsync(string, Func<ResourceEvent, bool>, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitforresourceasync-string-func-resourceevent-bool-cancellationtoken) : [Task<ResourceEvent>](/reference/api/csharp/aspire.hosting/resourceevent.md) -- Waits until a resource satisfies the specified predicate.
- [WaitForResourceHealthyAsync(string, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitforresourcehealthyasync-string-cancellationtoken) : [Task<ResourceEvent>](/reference/api/csharp/aspire.hosting/resourceevent.md) -- Waits for a resource to become healthy.
- [WaitForResourceHealthyAsync(string, WaitBehavior, CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#waitforresourcehealthyasync-string-waitbehavior-cancellationtoken) : [Task<ResourceEvent>](/reference/api/csharp/aspire.hosting/resourceevent.md) -- Waits for a resource to become healthy.
- [WatchAsync(CancellationToken)](/reference/api/csharp/aspire.hosting/resourcenotificationservice/methods.md#watchasync-cancellationtoken) : [IAsyncEnumerable<ResourceEvent>](/reference/api/csharp/aspire.hosting/resourceevent.md) -- Watch for changes to the state for all resources.
