public async static void AutoLights() { if (IsLightSensorEnabled) { if (LightSensor.Read() == GpioPinValue.High) { foreach (string item in lightSensorDevices) { lightsList[item].LightOn = true; } } else { foreach (string item in lightSensorDevices) { lightsList[item].LightOn = false; } } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (GroundFloorPage.Current != null) { GroundFloorPage.Current.SetLightButtonStatus(); } if (FirstFloorPage.Current != null) { FirstFloorPage.Current.SetLightButtonStatus(); } }); } }