//Sending messages to the IoT hub private async Task SendDeviceToCloudMessagesAsync() { information = new PerformanceCounters(); //Loop for sending messages while (!kill) { //Creating a telemetry object, setting data, sending over Iot Azure telemetry = new TelemetryDatapoint(device); //Cpu telemetry.Cpu = information.GetCPU(); telemetry.Cpu2 = information.GetFrequency(); telemetry.Percent = information.GetPercent(); telemetry.Thread = information.GetThreadCount(); telemetry.CpuTem = information.GetTemp(); telemetry.Processes = information.GetProcesesCount(); //Ram telemetry.Ram = information.GetRamAvailable(); telemetry.RamInUse = information.GetRamInUse(); telemetry.RamCache = information.GetRamCache(); telemetry.RamCommitted = information.GetRamCommitted(); telemetry.PagedPool = information.GetPagedPool(); telemetry.NonPagedPool = information.GetNonPagedPool(); //Disk telemetry.DiskReadTime = information.GetDiskReadTime(); telemetry.DiskWriteTime = information.GetDiskWriteTime(); telemetry.DiskReadBytes = information.GetReadBytes(); telemetry.DiskWriteBytes = information.GetWriteBytes(); telemetry.FreeMB = information.GetFreeMB(); telemetry.FreeSpace = information.GetFreeSpace(); telemetry.IdleTime = information.GetIdleTime(); telemetry.DiskTime = information.GetDiskTime(); //Wifi telemetry.DownloadRate = information.GetDownload(); telemetry.UploadRate = information.GetUpload(); telemetry.Bandwidth = information.GetBandwidth(); telemetry.PacketsReceived = information.GetPacketsReceived(); telemetry.PacketsSent = information.GetPacketsSent(); telemetry.Packets = information.GetPackets(); telemetry.ListTest = information.GetProcesses(); var messageString = JsonConvert.SerializeObject(telemetry); Message message = new Message(Encoding.ASCII.GetBytes(messageString)); await deviceClient.SendEventAsync(message); //Printing out message Console.WriteLine(messageString); Task.Delay(650).Wait(); } }