static void GetHostnameCallback(IAsyncResult result) { try { DeviceClient client = (DeviceClient)result.AsyncState; HostnameInformation info = client.EndGetHostname(result); Console.WriteLine("OK"); } catch (Exception exc) { Console.WriteLine(exc.Message); } }