Exemplo n.º 1
0
        private async void Poll()
        {
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(30));

            CancellationToken token    = _cts.Token;
            TimeSpan          interval = TimeSpan.Zero;

            while (!token.WaitHandle.WaitOne(interval))
            {
                try
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    await System.Threading.Tasks.Task.Run(() => _cpuManager.Reconnect());
                }
                catch (Exception ex)
                {
                    _log.Error($"PollingService.Poll", ex);
                }

                interval = TimeSpan.FromMilliseconds(ConfigurationProvider.PollingMilliseconds);
            }
        }