public async Task RunDeviceAsync() { deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Mqtt, new ClientOptions { ModelId = modelId }); tempSensor = new TemperatureSensor(deviceClient, "tempSensor1", logger); diag = new DiagnosticsInterface(deviceClient, "diag"); deviceInfo = new DeviceInformation(deviceClient, "deviceInfo"); sdkInfo = new SdkInformation(deviceClient, "sdkInfo"); await deviceInfo.ReportDeviceInfoPropertiesAsync(DeviceInfo.ThisDeviceInfo); await sdkInfo.ReportSdkInfoPropertiesAsync(); diag.OnRebootCommand += Diag_OnRebootCommand; tempSensor.OnTargetTempReceived += TempSensor_OnTargetTempReceived; await tempSensor.InitAsync(); await Task.Run(async() => { logger.LogWarning("Entering Device Loop"); while (!quitSignal.IsCancellationRequested) { await tempSensor.SendTemperatureTelemetryValueAsync(CurrentTemperature); await diag.SendWorkingTelemetryAsync(Environment.WorkingSet); logger.LogInformation("Sending workingset and temp " + CurrentTemperature); await Task.Delay(5000); } }); }