BeforeStartEvent Class
Definition
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 before the application starts.
public class BeforeStartEvent : Aspire.Hosting.Eventing.IDistributedApplicationEvent
type BeforeStartEvent = class
interface IDistributedApplicationEvent
Public Class BeforeStartEvent
Implements IDistributedApplicationEvent
- Inheritance
-
BeforeStartEvent
- Implements
Examples
Subscribe to the BeforeStartEvent event and resolve the distributed application model.
var builder = DistributedApplication.CreateBuilder(args);
builder.Eventing.Subscribe<BeforeStartEvent>(async (@event, cancellationToken) => {
var appModel = @event.ServiceProvider.GetRequiredService<DistributedApplicationModel>();
// Mutate the distributed application model.
});
Remarks
Subscribing to this event is analogous to implementing the BeforeStartAsync(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 BeforeStartAsync(DistributedApplicationModel, CancellationToken).
Constructors
BeforeStartEvent(IServiceProvider, DistributedApplicationModel) |
This event is published before the application starts. |
Properties
Model |
The DistributedApplicationModel instance. |
Services |
The IServiceProvider instance. |