共用方式為


AfterResourcesCreatedEvent Constructor

Definition

This event is published after all resources have been created.

public AfterResourcesCreatedEvent (IServiceProvider services, Aspire.Hosting.ApplicationModel.DistributedApplicationModel model);
new Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent : IServiceProvider * Aspire.Hosting.ApplicationModel.DistributedApplicationModel -> Aspire.Hosting.ApplicationModel.AfterResourcesCreatedEvent
Public Sub New (services As IServiceProvider, model As DistributedApplicationModel)

Parameters

services
IServiceProvider

The IServiceProvider instance.

Examples

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

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).

Applies to