There is some chance 'ready-to-show' event is fired before ReadyToShow event is registered #137

Closed
opened 2026-01-29 16:32:13 +00:00 by claunia · 4 comments
Owner

Originally created by @jijiechen on GitHub (Mar 28, 2018).

Originally assigned to: @GregorBiswanger on GitHub.

Sometimes, the BrowserWindow's ready-to-show is fired before the ReadyToShow event handler of CSharp object is synced and registered onto the BrowserWindow JavaScript object.
In this case, the ReadyToShow event handler will never be executed.

In the following code, the browserWindow would never be shown:

var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
    Width = 1152,
    Height = 864,
    Show = false
});

browserWindow.SetTitle("MyApp");
browserWindow.OnReadyToShow += () => browserWindow.Show();

This case occurred randomly and especially more frequent on Windows systems.
It seems by adding some status caching in BrowserWindow.js and invoke the event handler immediately if the event handler is bound after the 'ready-to-show' has been triggered once, we can solve this problem.

Originally created by @jijiechen on GitHub (Mar 28, 2018). Originally assigned to: @GregorBiswanger on GitHub. Sometimes, the BrowserWindow's `ready-to-show` is fired before the ReadyToShow event handler of CSharp object is synced and registered onto the BrowserWindow JavaScript object. In this case, the ReadyToShow event handler will never be executed. In the following code, the browserWindow would never be shown: ```cs var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Width = 1152, Height = 864, Show = false }); browserWindow.SetTitle("MyApp"); browserWindow.OnReadyToShow += () => browserWindow.Show(); ``` This case occurred randomly and especially more frequent on Windows systems. It seems by adding some status caching in `BrowserWindow.js` and invoke the event handler immediately if the event handler is bound after the 'ready-to-show' has been triggered once, we can solve this problem.
claunia added the question label 2026-01-29 16:32:13 +00:00
Author
Owner

@The-MAZZTer commented on GitHub (Feb 10, 2019):

I can confirm this on 0.0.9 and 0.0.11. My window is configured to open on ReadyToShow and half the time nothing happens when I run my program.

I'm on Windows 10.

@The-MAZZTer commented on GitHub (Feb 10, 2019): I can confirm this on 0.0.9 and 0.0.11. My window is configured to open on ReadyToShow and half the time nothing happens when I run my program. I'm on Windows 10.
Author
Owner

@GregorBiswanger commented on GitHub (May 22, 2019):

fixed in Electron.NET 5.22.12.

@GregorBiswanger commented on GitHub (May 22, 2019): fixed in Electron.NET 5.22.12.
Author
Owner

@LordKanelsnegle commented on GitHub (Jun 5, 2019):

I'm still encountering this error while using 5.22.12

@LordKanelsnegle commented on GitHub (Jun 5, 2019): I'm still encountering this error while using 5.22.12
Author
Owner

@schotime commented on GitHub (Jul 8, 2019):

I"m still getting this on 5.22.13

@schotime commented on GitHub (Jul 8, 2019): I"m still getting this on 5.22.13
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#137