private async void Check() { if (OnNewNotification == null) { return; } HueListenerEventData eventData = null; try { eventData = CreateEventDataFromLight(_webChecker.Check()); } catch (Exception ex) { eventData = new HueListenerEventData { EventType = EventType.Error, ErrorMessage = ex.Message }; } finally { if (_lastEventData == null || (eventData != null && _lastEventData.EventType != eventData.EventType)) { _lastEventData = eventData; Notify(eventData); } } }
private void Notify(HueListenerEventData eventData) { if (OnNewNotification == null) { return; } OnNewNotification(this, new HueNotificationEventArgs(eventData)); }
public void StopListener() { _lastEventData = null; _timer.Stop(); }