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

Closed
opened 2026-01-29 16:39:44 +00:00 by claunia · 6 comments
Owner

Originally created by @Dotneteer on GitHub (Jan 4, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

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.

Originally created by @Dotneteer on GitHub (Jan 4, 2020). Originally assigned to: @GregorBiswanger on GitHub. 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](https://github.com/ElectronNET/Electron.NET/files/4021717/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`: ```csharp // ... public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder .UseStartup<Startup>() .UseElectron(args); // --- Added this }); // ... ``` 9. Set up `Startup.cs`: ```csharp // --- 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(); }); ``` 10. 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](https://user-images.githubusercontent.com/4783390/71763338-33344300-2edb-11ea-8321-f3624ee3758f.png) ![Taskmgr_5k2ICKnU0m](https://user-images.githubusercontent.com/4783390/71763340-3deed800-2edb-11ea-800b-ef9888b8463c.png) 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.
claunia added the bug label 2026-01-29 16:39:44 +00:00
Author
Owner

@MaximeTasset commented on GitHub (Jan 31, 2020):

I don't understand why is it not possible to hook to the event via the option, it will be simpler to not have raise condition like that. Am I right?

PS: By the way, I Have the same issue even with version 5.30.1

@MaximeTasset commented on GitHub (Jan 31, 2020): I don't understand why is it not possible to hook to the event via the option, it will be simpler to not have raise condition like that. Am I right? PS: By the way, I Have the same issue even with version 5.30.1
Author
Owner

@Dotneteer commented on GitHub (Jan 31, 2020):

I'm a bit concerned that the owners of the project are pretty passive since the beginning of December 2019 :-(. This is not what a project with 4.2k stars deserves.

@Dotneteer commented on GitHub (Jan 31, 2020): I'm a bit concerned that the owners of the project are pretty passive since the beginning of December 2019 :-(. This is not what a project with 4.2k stars deserves.
Author
Owner

@Charnock commented on GitHub (Apr 4, 2020):

I was experiencing the same problem on version 7.30.2 and got the expected behavior with this.

var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
  Show = false
});

window.Show();
@Charnock commented on GitHub (Apr 4, 2020): I was experiencing the same problem on version 7.30.2 and got the expected behavior with this. ```C# var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false }); window.Show(); ```
Author
Owner

@GregorBiswanger commented on GitHub (Apr 18, 2020):

@Dotneteer We authors are both fathers at the moment.. and are therefore a bit limited in time.. I will work on a new version for the days.. But you can also support or sponsor us with pull requests :)

I'll take a closer look at your problem.

@GregorBiswanger commented on GitHub (Apr 18, 2020): @Dotneteer We authors are both fathers at the moment.. and are therefore a bit limited in time.. I will work on a new version for the days.. But you can also support or sponsor us with pull requests :) I'll take a closer look at your problem.
Author
Owner

@FQLin commented on GitHub (Apr 21, 2020):

I have the same problem on version 7.30.2,but netcoreapp5.0 priview project.

@FQLin commented on GitHub (Apr 21, 2020): I have the same problem on version 7.30.2,but netcoreapp5.0 priview project.
Author
Owner

@GregorBiswanger commented on GitHub (Apr 21, 2020):

Fixed in the next Electron.NET Version 8.31.1.

@GregorBiswanger commented on GitHub (Apr 21, 2020): Fixed in the next Electron.NET Version 8.31.1.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#440