Program.cscsharp

Documentation

Lilith.DesktopWeb2App (Version 3)

Windows desktop shell (WebView2 + local Kestrel) hosting Lilith.RazorWebGui for Version 3.

dotnet run --project Lilith.DesktopWeb2App.csproj

Requires [WebView2 Runtime](https://developer.microsoft.com/microsoft-edge/webview2/).

using Lilith.RazorWebGui;namespace Lilith.DesktopWeb2App;internal static class Program{    [STAThread]    private static void Main(string[] args)    {        ApplicationConfiguration.Initialize();        int port = TcpPort.FindFree();        string url = $"http://127.0.0.1:{port}";        string[] webArgs = ["--urls", url, ..args];        using var ready = new ManualResetEventSlim(false);        var hostTask = Task.Run(() =>        {            var app = LilithWebApplication.Build(webArgs);            app.Lifetime.ApplicationStarted.Register(() => ready.Set());            app.Run();        });        if (!ready.Wait(TimeSpan.FromSeconds(60)))        {            MessageBox.Show("Lilith web host failed to start.", "Lilith Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);            return;        }        Application.Run(new MainForm(url));    }}