mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-14 13:44:47 +00:00
Change IsReady logic to also wait for connection to be open. This is to prevent actions occurring before the app can act upon them.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Quobject.SocketIoClientDotNet.Client;
|
||||
|
||||
namespace ElectronNET.API
|
||||
{
|
||||
@@ -12,10 +13,14 @@ namespace ElectronNET.API
|
||||
{
|
||||
public LifetimeServiceHost(IHostApplicationLifetime lifetime)
|
||||
{
|
||||
lifetime.ApplicationStarted.Register(() =>
|
||||
lifetime.ApplicationStarted.Register(async () =>
|
||||
{
|
||||
App.Instance.IsReady = true;
|
||||
// wait till the socket is open before setting app to ready
|
||||
while(BridgeConnector.Socket.Io().ReadyState != Manager.ReadyStateEnum.OPEN) {
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
App.Instance.IsReady = true;
|
||||
Console.WriteLine("ASP.NET Core host has fully started.");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user