public override async void BeforeOpenModal(dynamic options)
        {
            base.OnInitialize();

            _starting = true;

            while (_starting)
            {
                var result = await _service.StartAsync();

                if (result.Success)
                {
                    TryClose(true);
                    break;
                }

                await Task.Delay(DelayBetweenServiceStartAttempts);
            }
        }
Beispiel #2
0
        private async Task InvokeAction(Func <Task> action)
        {
            if (!_baseFilteringEngineService.Running())
            {
                _modals.Show <BfeWarningModalViewModel>();
                return;
            }

            if (!_vpnService.Enabled())
            {
                bool?result = _modals.Show <DisabledServiceModalViewModel>();
                if (!result.HasValue || !result.Value)
                {
                    return;
                }

                _vpnService.Enable();
                await _vpnService.StartAsync();
            }

            while (true)
            {
                try
                {
                    await action();

                    break;
                }
                catch (EndpointNotFoundException)
                {
                    bool?result = _modals.Show <ServiceStartModalViewModel>();
                    if (result == null || !result.Value)
                    {
                        break;
                    }
                }
                catch (Exception e) when(IsConnectionException(e))
                {
                    _logger.Error(e);
                }
            }
        }