private async void initialize() { if (EventHandlerForDevice.Current.Device == null) { stackpanel2.Visibility = Visibility.Collapsed; MainPage.Current.NotifyUser("Device is not connected", NotifyType.ErrorMessage); } else { MainPage.Current.NotifyUser("Connected to " + EventHandlerForDevice.Current.DeviceInformation.Id, NotifyType.StatusMessage); // So we can reset future tasks ResetReadCancellationTokenSource(); ResetWriteCancellationTokenSource(); } DeviceInformationCollection deviceInfoCollection = await DeviceInformation.FindAllAsync(LightSensor.GetDeviceSelector(), Constants.RequestedProperties); foreach (DeviceInformation deviceInfo in deviceInfoCollection) { lightSensor = await LightSensor.FromIdAsync(deviceInfo.Id); } }