title: What do you think of my IDisposable pattern implementation?
body: <p>What do you think of the following <code>IDisposable</code> pattern implementation?</p>
  
  <pre><code>public class Connection : IDisposable 
  {
      private Socket _socket;
  
      public bool IsConnected()
      {
          if (_socket.Poll(1, SelectMode.SelectRead) &amp;&amp; _socket.Available == 0)
              return false;
          return true;
      }
  
      public void Disconnect()
      {
          if (m_socket != null &amp;&amp; IsConnected())
          {
              try
              {
                  _socket.Shutdown(SocketShutdown.Both);
                  _socket.Disconnect(false);
              }
              catch (SocketException se)
              {
                  System.Console.WriteLine(se.Message);
              }
          }
      }
  
      ~Connection()
      {
          Dispose(false);
      }
  
      private void Dispose(bool disposing)
      {
          if (!IsConnected())
          {
              if (disposing)
              {
                  Disconnect();
              }
              else
              {
                  AppDomain currentDomain = AppDomain.CurrentDomain;
                  if (currentDomain.IsFinalizingForUnload() &amp;&amp; !Environment.HasShutdownStarted)
                  {
                       System.Console.WriteLine("Client failed to call Destroy");
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I was given this error using the code above: </p>
  
  <blockquote>
    <p>{"An operation was attempted on something that is not a socket"}
    System.Net.Sockets.Socket.Poll(Int32 microSeconds, SelectMode mode)</p>
  </blockquote>