Skip to content

Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false #361

@Dotneteer

Description

@Dotneteer

ElectronNET version: 7.30.2
.NET Core 3.0.1 (produces the same issue with v3.1.0)

(project that reproduces the behavior is attached)

BlazorOnReadyToShowIssue.zip

Create an ElectronNET based Blazor project with the standard steps

  1. mkdir BlazorOnReadyIssue
  2. cd BlazorOnReadyIssue
  3. dotnet new blazorserver --no-https
  4. dotnet add package ElectronNET.API
  5. dotnet new tool-manifest
  6. dotnet tool install ElectronNET.CLI
  7. dotnet electronize init
  8. Set up Program.cs:
// ...
public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
             webBuilder
                 .UseStartup<Startup>()
                 .UseElectron(args);  // --- Added this
        });
// ...
  1. Set up Startup.cs:
// --- At the end of Configure
// ...
Task.Run(async () =>
{
    var browserWindow = await Electron.WindowManager.CreateWindowAsync(
        new BrowserWindowOptions
        {
            Title = "OnReadyToShow",
            Width = 1152,
            Height = 864,
            Show = false // --- When set to true, project works properly
        });
    browserWindow.OnReadyToShow += () => browserWindow.Show();
});
  1. Run the project (either with Ctrl+F5 or electronize start)

Expected behavior: The Electron Shell window is displayed with the Blazor App.

Issue: The Electron Shell window does not display.

VsDebugConsole_mpnXKwDexe
Taskmgr_5k2ICKnU0m

Whenever I change the Show property of BrowserWindopOptions to true, the project works fine, but, of course, for a few seconds an empty page is displayed according to the normal behavior.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions