| File: AppHost.cs | Web Access |
| Project: src\playground\CustomResources\CustomResources.AppHost\CustomResources.AppHost.csproj (CustomResources.AppHost) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using CustomResources.AppHost; using Microsoft.Extensions.Configuration; var builder = DistributedApplication.CreateBuilder(args); builder.AddTalkingClock("talking-clock"); builder.AddTestResource("test"); builder.AddParameter("p0"); // Simulates a slow BeforeStartEvent subscriber, e.g. `dotnet run -- --BeforeStartDelaySeconds 15`. // Startup logs (AppHost version, "Distributed application starting.") should still appear immediately. if (builder.Configuration.GetValue<int?>("BeforeStartDelaySeconds") is { } beforeStartDelaySeconds) { builder.Eventing.Subscribe<BeforeStartEvent>(async (_, cancellationToken) => { Console.WriteLine($"BeforeStartEvent subscriber delaying startup for {beforeStartDelaySeconds}s..."); await Task.Delay(TimeSpan.FromSeconds(beforeStartDelaySeconds), cancellationToken); Console.WriteLine("BeforeStartEvent subscriber finished."); }); } #if !SKIP_DASHBOARD_REFERENCE // This project is only added in playground projects to support development/debugging // of the dashboard. It is not required in end developer code. Comment out this code // or build with `/p:SkipDashboardReference=true`, to test end developer // dashboard launch experience, Refer to Directory.Build.props for the path to // the dashboard binary (defaults to the Aspire.Dashboard bin output in the // artifacts dir). builder.AddDotnetProject(KnownResourceNames.AspireDashboard, "../../../src/Aspire.Dashboard/Aspire.Dashboard.csproj"); #endif builder.Build().Run();