diff --git a/NET8Blazor/PhotinoNetApp/Program.cs b/NET8Blazor/PhotinoNetApp/Program.cs index fc609bf..9920f90 100644 --- a/NET8Blazor/PhotinoNetApp/Program.cs +++ b/NET8Blazor/PhotinoNetApp/Program.cs @@ -2,6 +2,9 @@ using System.Drawing; using PhotinoNET; using PhotinoNetApp.Components; +// +// Standard .NET 8 template for web apps: +// var builder = WebApplication.CreateBuilder(); builder.Services.AddRazorComponents() @@ -9,26 +12,42 @@ builder.Services.AddRazorComponents() builder.WebHost.UseWebRoot("wwwroot"); builder.WebHost.UseStaticWebAssets(); + +// I specified the URL with a port: builder.WebHost.UseUrls("http://localhost:5000"); var app = builder.Build(); - app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); +// +// End of standard template +// + +// Using a cancellation token source, so we can exit the web server later: using var webServerCancellation = new CancellationTokenSource(); + +// Run the webserver async in the background (no await used here): var webServerTask = app.RunAsync(webServerCancellation.Token); +// Create the Photino window: var window = new PhotinoWindow() .SetTitle("Test App") .SetUseOsDefaultSize(false) .SetSize(new Size(1024, 900)) .Center() .SetResizable(true) + + // ... and load the web content at the URL / port: .Load("http://localhost:5000"); +// Wait until the Photino window was closed: window.WaitForClose(); + +// Cancel the webserver using the token: webServerCancellation.Cancel(); + +// Wait for the server to stop: await webServerTask; \ No newline at end of file