AfterResourcesCreatedEvent Constructors
Class Constructors 1 member
This event is published after all resources have been created.
Constructor(IServiceProvider, DistributedApplicationModel) Section titled Constructor(IServiceProvider, DistributedApplicationModel) This event is published after all resources have been created.
public class AfterResourcesCreatedEvent{ public AfterResourcesCreatedEvent( IServiceProvider services, DistributedApplicationModel model) { // ... }}Parameters
services IServiceProvider The IServiceProvider instance. model DistributedApplicationModel The DistributedApplicationModel instance. Remarks
Subscribing to this event is analogous to implementing the
IDistributedApplicationLifecycleHook.AfterResourcesCreatedAsync method. This event provides access to the IServiceProvider interface to resolve dependencies including DistributedApplicationModel service which is passed in as an argument in IDistributedApplicationLifecycleHook.AfterResourcesCreatedAsync. Examples
Subscribe to the 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.});