Ejemplo n.º 1
0
        public async Task UpdateReportedTwinAsync(string deviceId, string twinName, int twinValue)
        {
            try
            {
                Microsoft.Azure.Devices.Client.DeviceClient device = Microsoft.Azure.Devices.Client.DeviceClient.CreateFromConnectionString(this.Configuration.IoTHubConnectionString, deviceId);
                var twinCollection = new TwinCollection();
                twinCollection[twinName] = twinValue;
                await device.UpdateReportedPropertiesAsync(twinCollection);

                device.Dispose();
            }
            catch (System.InvalidOperationException)
            {
            }
        }
Ejemplo n.º 2
0
        private async void MainPage_Unloaded(object sender, RoutedEventArgs e)
        {
            await device.CloseAsync();

            device.Dispose();
        }