# DistributedApplicationResourceEventSubscription Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [DistributedApplicationResourceEventSubscription](/reference/api/csharp/aspire.hosting/distributedapplicationresourceeventsubscription.md)
- Kind: `Constructors`
- Members: `1`

Represents a subscription to an event that is published during the lifecycle of the AppHost for a specific resource.

## DistributedApplicationResourceEventSubscription(IResource?, Func<IDistributedApplicationResourceEvent, CancellationToken, Task>)

- Name: `Constructor(IResource?, Func<IDistributedApplicationResourceEvent, CancellationToken, Task>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/Eventing/DistributedApplicationEventSubscription.cs#L26-L31)

Represents a subscription to an event that is published during the lifecycle of the AppHost for a specific resource.

```csharp
public class DistributedApplicationResourceEventSubscription
{
    public DistributedApplicationResourceEventSubscription(
        IResource? resource,
        Func<IDistributedApplicationResourceEvent, CancellationToken, Task> callback)
    {
        // ...
    }
}
```

## Parameters

- `resource` ([IResource?](/reference/api/csharp/aspire.hosting/iresource.md))
- `callback` (`Func<IDistributedApplicationResourceEvent, CancellationToken, Task>`)
