Skip to content
DocsTry Aspire
DocsTry

DistributedApplicationEventing Methods

ClassMethods5 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))
{
// ...
}
}
eventTThe event.
cancellationTokenCancellationTokenoptionalA cancellation token.
TaskA 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))
{
// ...
}
}
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 class DistributedApplicationEventing
{
public 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 class DistributedApplicationEventing
{
public 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)
Unsubscribe from an event.
public class DistributedApplicationEventing
{
public void Unsubscribe(
DistributedApplicationEventSubscription subscription)
{
// ...
}
}
subscriptionDistributedApplicationEventSubscriptionThe specific subscription to unsubscribe.