Skip to content
Docs Try Aspire

DistributedApplicationEventing Methods

Class Methods 5 members
Supports publishing and subscribing to events which are executed during the AppHost lifecycle.
PublishAsync(T, CancellationToken) Section titled PublishAsync(T, CancellationToken) Task
Publishes an event to all subscribes of the specific event type.
public class DistributedApplicationEventing
{
public Task PublishAsync<T>(
T @event,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
event T The event.
cancellationToken CancellationToken optional A cancellation token.
Task A task that can be awaited.
PublishAsync(T, EventDispatchBehavior, CancellationToken) Section titled PublishAsync(T, EventDispatchBehavior, CancellationToken) Task
Publishes an event to all subscribes of the specific event type.
public class DistributedApplicationEventing
{
public Task PublishAsync<T>(
T @event,
EventDispatchBehavior dispatchBehavior,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
event T The event.
dispatchBehavior EventDispatchBehavior The dispatch behavior for the event.
cancellationToken CancellationToken optional A cancellation token.
Task A task that can be awaited.
Subscribes a callback to a specific event type within the AppHost.
public class DistributedApplicationEventing
{
public DistributedApplicationEventSubscription Subscribe<T>(
Func<T, CancellationToken, Task> callback)
{
// ...
}
}
callback Func<T, CancellationToken, Task> A callback to handle the event.
DistributedApplicationEventSubscription A subscription instance which can be used to unsubscribe
Subscribes a callback to a specific event type
public class DistributedApplicationEventing
{
public DistributedApplicationEventSubscription Subscribe<T>(
IResource resource,
Func<T, CancellationToken, Task> callback)
{
// ...
}
}
resource IResource The resource instance associated with the event.
callback Func<T, CancellationToken, Task> A callback to handle the event.
DistributedApplicationEventSubscription A subscription instance which can be used to unsubscribe.
Unsubscribe(DistributedApplicationEventSubscription) Section titled Unsubscribe(DistributedApplicationEventSubscription)
Unsubscribe from an event.
public class DistributedApplicationEventing
{
public void Unsubscribe(
DistributedApplicationEventSubscription subscription)
{
// ...
}
}
subscription DistributedApplicationEventSubscription The specific subscription to unsubscribe.