예제 #1
0
        public async Task InitAsync(CancellationToken ct)
        {
            _logger.Verbose("Preparing to init {windowName} window (id: {windowId}) with url {windowUrl}", Name, Id, Url);
            using (_logger.Timed("Initiating {windowName} window", Name))
            {
                Window = await ElectronNET.API.Electron.WindowManager.CreateWindowAsync(Options, Url);
                await OnCreatedAsync(Window, ct);

                Window.OnClosed += () =>
                {
                    _logger.Debug("Window {windowName} has been closed.", Name);
                    if (_isDisposing)
                    {
                        _logger.Information("Disposing {windowName}. Window wont be recreated", Name);
                        return;
                    }
                    _logger.Information("Recreating window {windowName}", Name);
                    InitAsync(CancellationToken.None).GetAwaiter().GetResult();
                };
            }
        }