new DeviceClient(myDevice.AssignedHub, registrationid, saskey, MqttQoSLevel.AtMostOnce); var res = client.Open(); if (!res) { Debug.WriteLine("can't open the device"); return; } else { Debug.WriteLine("Open the device"); Console.WriteLine("Open the device"); } Thread.Sleep(5000); }