# DistributedApplicationEventing

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

Supports publishing and subscribing to events which are executed during the AppHost lifecycle.

## Definition

```csharp
namespace Aspire.Hosting.Eventing;

public class DistributedApplicationEventing
    : Aspire.Hosting.Eventing.IDistributedApplicationEventing
{
    // ...
}
```

## Constructors

- [DistributedApplicationEventing](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/constructors.md#constructor)

## Methods

- [PublishAsync(T, CancellationToken)](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/methods.md#publishasync-t-cancellationtoken) : `Task` -- Publishes an event to all subscribes of the specific event type.
- [PublishAsync(T, EventDispatchBehavior, CancellationToken)](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/methods.md#publishasync-t-eventdispatchbehavior-cancellationtoken) : `Task` -- Publishes an event to all subscribes of the specific event type.
- [Subscribe(Func<T, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/methods.md#subscribe-func-t-cancellationtoken-task) : [DistributedApplicationEventSubscription](/reference/api/csharp/aspire.hosting/distributedapplicationeventsubscription.md) -- Subscribes a callback to a specific event type within the AppHost.
- [Subscribe(IResource, Func<T, CancellationToken, Task>)](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/methods.md#subscribe-iresource-func-t-cancellationtoken-task) : [DistributedApplicationEventSubscription](/reference/api/csharp/aspire.hosting/distributedapplicationeventsubscription.md) -- Subscribes a callback to a specific event type
- [Unsubscribe(DistributedApplicationEventSubscription)](/reference/api/csharp/aspire.hosting/distributedapplicationeventing/methods.md#unsubscribe-distributedapplicationeventsubscription) -- Unsubscribe from an event.
