chromelyapps / Chromely

Build Cross Platform HTML Desktop Apps on .NET using native GUI, HTML5, JavaScript, CSS, Owin, AspNetCore (MVC, RazorPages, Blazor)
MIT License
2.98k stars 280 forks source link

Added helper classes for Port / URL discovery and cleanup of the host thread #330

Closed Hecatron closed 2 years ago

Hecatron commented 3 years ago

Hi, I've added a couple of helper class's which might come in useful to simplify some of the demo / template apps

I've got an example of the code in use here https://github.com/Hecatron-Forks/MudBlazor.Templates/tree/master/MudBlazor.Template.DefaultBlazor/Desktop/DefaultBlazor.Desktop.Chromely

I'm not sure if the names of the class's / namespace is ok but I did notice that different demos had different ways of setting things up such as this one https://github.com/chromelyapps/demo-projects/blob/master/blazor/ServerAppDemo/ServerAppUtil.cs

This one uses a Memory mapped file to pass the port number to child processes But from what I can gather that isn't required (or at least it isn't with the latest version of Chromely I've tested with) and MemoryMappedFile isn't cross platform But the method for searching for a free network port was better than the one I was using myself so I nabbed that bit of code.

Anyway I figured it might just be an idea to put some of the common code shared between the demos into a couple of class's in the library to help set things up / reduce code duplication