AfterResourcesCreatedEvent Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This event is published after all resources have been created.
public class AfterResourcesCreatedEvent : Aspire.Hosting.Eventing.IDistributedApplicationEvent
type AfterResourcesCreatedEvent = class
interface IDistributedApplicationEvent
Public Class AfterResourcesCreatedEvent
Implements IDistributedApplicationEvent
- Inheritance
-
AfterResourcesCreatedEvent
- Implements
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.
});
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).
After |
This event is published after all resources have been created. |
Model |
The DistributedApplicationModel instance. |
Services |
The IServiceProvider instance. |
Produit | Versions |
---|---|
.NET Aspire | 8.0.0, 9.0.0, 9.1.0 |