/// <summary> /// Polls the state of the hue gateway. /// </summary> /// <param name="sender">The sender.</param> /// <param name="elapsedEventArgs">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> private void PollHueGatewayState(object sender, ElapsedEventArgs elapsedEventArgs) { _lightService.GetAllStatusAsync(data => { if (_lightPollingTimer == null) { return; } Logger.Debug("Hue Driver received light data response from bridge"); UpdateLightState(data.ToList()); IsReady = true; _lightPollingTimer.Interval = _pollingInterval; _lightPollingTimer.Start(); }, exception => { if (_lightPollingTimer == null) { return; } IsReady = false; Logger.ErrorFormat("Hue Driver received error response: {0}", exception.GetBaseException().Message); _lightPollingTimer.Interval = Math.Min(_lightPollingTimer.Interval * 1.5, 60000); _lightPollingTimer.Start(); }); }