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

Open
opened 2026-01-29 16:32:11 +00:00 by claunia · 0 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:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#134