Skip to content
DocsTry Aspire
DocsTry

IDistributedApplicationEventing Methods

InterfaceMethods5 members
Supports publishing and subscribing to events which are executed during the AppHost lifecycle.
PublishAsync(T, CancellationToken)Section titled PublishAsync(T, CancellationToken)abstractTask
Publishes an event to all subscribes of the specific event type.
public interface IDistributedApplicationEventing
{
public abstract Task PublishAsync<T>(
T @event,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
eventTThe event.
cancellationTokenCancellationTokenoptionalA cancellation token.
TaskA task that can be awaited.
PublishAsync(T, EventDispatchBehavior, CancellationToken)Section titled PublishAsync(T, EventDispatchBehavior, CancellationToken)abstractTask
Publishes an event to all subscribes of the specific event type.
public interface IDistributedApplicationEventing
{
public abstract Task PublishAsync<T>(
T @event,
EventDispatchBehavior dispatchBehavior,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
eventTThe event.
dispatchBehaviorEventDispatchBehaviorThe dispatch behavior for the event.
cancellationTokenCancellationTokenoptionalA cancellation token.
TaskA task that can be awaited.
Subscribes a callback to a specific event type within the AppHost.
public interface IDistributedApplicationEventing
{
public abstract DistributedApplicationEventSubscription Subscribe<T>(
Func<T, CancellationToken, Task> callback)
{
// ...
}
}
callbackFunc<T, CancellationToken, Task>A callback to handle the event.
DistributedApplicationEventSubscriptionA subscription instance which can be used to unsubscribe
Subscribes a callback to a specific event type
public interface IDistributedApplicationEventing
{
public abstract DistributedApplicationEventSubscription Subscribe<T>(
IResource resource,
Func<T, CancellationToken, Task> callback)
{
// ...
}
}
resourceIResourceThe resource instance associated with the event.
callbackFunc<T, CancellationToken, Task>A callback to handle the event.
DistributedApplicationEventSubscriptionA subscription instance which can be used to unsubscribe.
Unsubscribe(DistributedApplicationEventSubscription)Section titled Unsubscribe(DistributedApplicationEventSubscription)abstract
Unsubscribe from an event.
public interface IDistributedApplicationEventing
{
public abstract void Unsubscribe(
DistributedApplicationEventSubscription subscription)
{
// ...
}
}
subscriptionDistributedApplicationEventSubscriptionThe specific subscription to unsubscribe.