title: (C#) How to check if iot device is able to send to IoTHub
body: <p>I'm using amqp to send messages from my iot devices to Azure IoTHub. I'm writing a program in C# and I want to check if the devices are able to establish a connection with iot hub. 
  What would be the best way of achieving this? Is it possible to create a callback function?</p>
  
  <p>I noticed that one of my devices are on a closed network, that is the amqp port is blocked. But the device logs that It's sending messages to IoT Hub (no exceptions thrown) and when I check Iot Hub no messages have been received. This is why I want to check if the device is able to establish a connection with IoT Hub</p>
  
  <p>The java sdk has a eventcallback class but not C#, or am I missing something?</p>
  
  <p><code>protected static class EventCallback implements IotHubEventCallback { 
      public void execute(IotHubStatusCode status, Object context) { 
          System.out.println("IoT Hub responded to message with status " + status.name()); 
      } 
  }</code></p>
  
  <p>Edit: 
  Would this be a good implementation?</p>
  
  <p><code>
      try {
          client = DeviceClient.CreateFromConnectionString("***", TransportType.Amqp);
          var task = client.OpenAsync();
          task.Wait(30000); // wait for 30 sec 
          if (task.IsCompleted) {
              Console.WriteLine("Connected");
              await client.CloseAsync();
          }
          else {
              throw new Exception("Time out");
          }
      }
      catch (Exception e) {
          Console.WriteLine("Error");
      }
  </code></p>