Lire en anglais

Partager via


AfterResourcesCreatedEvent Class

Definition

This event is published after all resources have been created.

C#
public class AfterResourcesCreatedEvent : Aspire.Hosting.Eventing.IDistributedApplicationEvent
Inheritance
AfterResourcesCreatedEvent
Implements

Examples

Subscribe to the AfterResourcesCreatedEvent event and resolve the distributed application model.

C#
var builder = DistributedApplication.CreateBuilder(args);
builder.Eventing.Subscribe<AfterResourcesCreatedEvent>(async (@event, cancellationToken) => {
  var appModel = @event.ServiceProvider.GetRequiredService<DistributedApplicationModel>();
  // Run post startup logic.
});

Remarks

Subscribing to this event is analogous to implementing the AfterResourcesCreatedAsync(DistributedApplicationModel, CancellationToken) method. This event provides access to the IServiceProvider interface to resolve dependencies including DistributedApplicationModel service which is passed in as an argument in AfterResourcesCreatedAsync(DistributedApplicationModel, CancellationToken).

Constructors

AfterResourcesCreatedEvent(IServiceProvider, DistributedApplicationModel)

This event is published after all resources have been created.

Properties

Applies to

Produit Versions
.NET Aspire 8.0.0, 9.0.0, 9.1.0