private static async Task SendDeviceToCloudMessageAsync() { try { string messageString = ""; messageString = JsonConvert.SerializeObject(data); data.Clear(); var message = new Message(Encoding.ASCII.GetBytes(messageString)); await serviceClient.SendAsync(targetDevice, message); Console.WriteLine("{0} > Sending message: {1}", DateTime.Now, messageString); } catch (Exception ex) { Console.WriteLine(ex); } }