private async void HandleGlobalResolver(bool actAsGlobalGateway)
        {
            IsWorkingOnPrimaryService = true;
            if (actAsGlobalGateway)
            {
                PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalAddress = Global.GlobalGatewayAddress;
                PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalPort    = Global.PrimaryResolverPort;
                PrimaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Primary);
                await Task.Run(() => { PrimaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false);

                Thread.Sleep(Global.ServiceRestartTime);
                _isPrimaryResolverRunning = PrimaryDnsCryptProxyManager.IsDnsCryptProxyRunning();
                NotifyOfPropertyChange(() => IsPrimaryResolverRunning);
                PrimaryResolverTitle = string.Format("{0} ({1}:{2})",
                                                     LocalizationEx.GetUiString("default_settings_primary_header", Thread.CurrentThread.CurrentCulture),
                                                     Global.GlobalGatewayAddress, Global.PrimaryResolverPort);
            }
            else
            {
                PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalAddress = Global.PrimaryResolverAddress;
                PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.LocalPort    = Global.PrimaryResolverPort;
                PrimaryDnsCryptProxyManager.WriteRegistry(DnsCryptProxyType.Primary);
                await Task.Run(() => { PrimaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false);

                Thread.Sleep(Global.ServiceRestartTime);
                _isPrimaryResolverRunning = PrimaryDnsCryptProxyManager.IsDnsCryptProxyRunning();
                NotifyOfPropertyChange(() => IsPrimaryResolverRunning);
                PrimaryResolver.LocalPort = Global.PrimaryResolverPort;                 // reset the resolver port
                PrimaryResolverTitle      = string.Format("{0}",
                                                          LocalizationEx.GetUiString("default_settings_primary_header", Thread.CurrentThread.CurrentCulture));
            }
            IsWorkingOnPrimaryService = false;
        }
        private async void RestartService(DnsCryptProxyType dnsCryptProxyType)
        {
            if (dnsCryptProxyType == DnsCryptProxyType.Primary)
            {
                IsWorkingOnPrimaryService = true;
                await Task.Run(() => { PrimaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false);

                Thread.Sleep(Global.ServiceRestartTime);
                _isPrimaryResolverRunning = PrimaryDnsCryptProxyManager.IsDnsCryptProxyRunning();
                NotifyOfPropertyChange(() => IsPrimaryResolverRunning);
                IsWorkingOnPrimaryService = false;
            }
            else
            {
                IsWorkingOnSecondaryService = true;
                await Task.Run(() => { SecondaryDnsCryptProxyManager.Restart(); }).ConfigureAwait(false);

                Thread.Sleep(Global.ServiceRestartTime);
                _isSecondaryResolverRunning = SecondaryDnsCryptProxyManager.IsDnsCryptProxyRunning();
                NotifyOfPropertyChange(() => IsSecondaryResolverRunning);
                IsWorkingOnSecondaryService = false;
            }
        }