コード例 #1
0
        protected async override void OnStart(string[] args)
        {
            if (string.IsNullOrEmpty(DusApi.Default.DomainName) ||
                string.IsNullOrEmpty(DusApi.Default.AccessKey) ||
                string.IsNullOrEmpty(DusApi.Default.SecretKey))
            {
                throw new NullReferenceException(
                          "A domain name, access key, or secret key has " +
                          "not been specified in the application config file. " +
                          "Please specify these settings and try again.");
            }

            EncryptConfigSection("userSettings/DNSUpdaterService.Properties.DusApi");

            if (Environment.UserInteractive)
            {
                var registrar = RegistrarFactory.CreateRegistrar();
                await registrar.UpdateRegistrar(EventLog);
            }
            else
            {
                Timer timer = new Timer()
                {
                    Interval = 300000
                };
                timer.Elapsed += new ElapsedEventHandler(OnTimer);
                timer.Start();
            }
        }
コード例 #2
0
 private async void OnTimer(object sender, ElapsedEventArgs e)
 {
     var registrar = RegistrarFactory.CreateRegistrar();
     await registrar.UpdateRegistrar(EventLog);
 }