예제 #1
0
        private async void MonitorServiceRegistration(CancellationToken _cancellationToken)
        {
            try
            {
                await Task.Delay(RegistrationCheckPeriodInSeconds * 1000, _cancellationToken);

                while (!_cancellationToken.IsCancellationRequested)
                {
                    if (_registration != null)
                    {
                        var serviceInstanceInfo = await _discovery.FindServiceByInstanceName(_registration.InstanceName);

                        if (serviceInstanceInfo == null)
                        {
                            _registration = await _discovery.RegisterService();
                        }
                    }
                    await Task.Delay(RegistrationCheckPeriodInSeconds * 1000, _cancellationToken);
                }
                _log.Info("Service registration monitor stopped.");
            }
            catch (OperationCanceledException)
            {
                _log.Info("Service registration monitor stopped.");
            }
        }