# DistributedApplicationEventingExtensions

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

Provides extension methods for subscribing to [IDistributedApplicationEvent](/reference/api/csharp/aspire.hosting/idistributedapplicationevent.md) and [IDistributedApplicationResourceEvent](/reference/api/csharp/aspire.hosting/idistributedapplicationresourceevent.md) events.

## Definition

```csharp
namespace Aspire.Hosting;

public static class DistributedApplicationEventingExtensions
{
    // ...
}
```

## Methods

- [OnAfterPublish(T, Func<AfterPublishEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onafterpublish-t-func-afterpublishevent-cancellationtoken-task) : `T` `extension` `ats ignored` -- Subscribes a callback to the [AfterPublishEvent](/reference/api/csharp/aspire.hosting/afterpublishevent.md) event within the AppHost.
- [OnBeforePublish(T, Func<BeforePublishEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onbeforepublish-t-func-beforepublishevent-cancellationtoken-task) : `T` `extension` `ats ignored` -- Subscribes a callback to the [BeforePublishEvent](/reference/api/csharp/aspire.hosting/beforepublishevent.md) event within the AppHost.
- [OnBeforeResourceStarted(IResourceBuilder<T>, Func<T, BeforeResourceStartedEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onbeforeresourcestarted-iresourcebuilder-t-func-t-beforeresourcestartedevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [BeforeResourceStartedEvent](/reference/api/csharp/aspire.hosting/beforeresourcestartedevent.md) event within the AppHost.
- [OnBeforeStart(T, Func<BeforeStartEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onbeforestart-t-func-beforestartevent-cancellationtoken-task) : `T` `extension` `ats ignored` -- Subscribes a callback to the [BeforeStartEvent](/reference/api/csharp/aspire.hosting/beforestartevent.md) event within the AppHost.
- [OnConnectionStringAvailable(IResourceBuilder<T>, Func<T, ConnectionStringAvailableEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onconnectionstringavailable-iresourcebuilder-t-func-t-connectionstringavailableevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [ConnectionStringAvailableEvent](/reference/api/csharp/aspire.hosting/connectionstringavailableevent.md) event for `builder`.
- [OnInitializeResource(IResourceBuilder<T>, Func<T, InitializeResourceEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#oninitializeresource-iresourcebuilder-t-func-t-initializeresourceevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [InitializeResourceEvent](/reference/api/csharp/aspire.hosting/initializeresourceevent.md) event for `builder`.
- [OnResourceEndpointsAllocated(IResourceBuilder<T>, Func<T, ResourceEndpointsAllocatedEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onresourceendpointsallocated-iresourcebuilder-t-func-t-resourceendpointsallocatedevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [ResourceEndpointsAllocatedEvent](/reference/api/csharp/aspire.hosting/resourceendpointsallocatedevent.md) event for `builder`.
- [OnResourceReady(IResourceBuilder<T>, Func<T, ResourceReadyEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onresourceready-iresourcebuilder-t-func-t-resourcereadyevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [ResourceReadyEvent](/reference/api/csharp/aspire.hosting/resourcereadyevent.md) event for `builder`.
- [OnResourceStopped(IResourceBuilder<T>, Func<T, ResourceStoppedEvent, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventingextensions/methods.md#onresourcestopped-iresourcebuilder-t-func-t-resourcestoppedevent-cancellationtoken-task) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Subscribes a callback to the [ResourceStoppedEvent](/reference/api/csharp/aspire.hosting/resourcestoppedevent.md) event for `builder`.
