title: the Difference of TIdTCPConnection.Disconnect and TIdIOHandler.Close
body: <p>I use Indy 10.6.2.5298.</p>
  
  <p>What is the difference of TIdTCPConnection.Disconnect and TIdIOHandler.Close? Both of them disconnect the line but sometimes the former makes an access violation error.</p>
  
  <p>I am sorry that I can't understand it through the help documents and their source codes.</p>
  
  <pre><code>type
    TForm1 = class(TForm)
      IdTCPServer1: TIdTCPServer;
      procedure FormClick(Sender: TObject);
      procedure IdTCPServer1Execute(AContext: TIdContext);
    private
      TestContext: TIdContext;
    end;
  
  procedure TForm1.FormClick(Sender: TObject);
  begin
    TestContext.Connection.Disconnect; // access violation
  
    TestContext.Connection.IOHandler.Close; // always works well
  end;
  
  procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
  begin
    TestContext := AContext;
  
    AContext.Connection.Disconnect; // works well
  end;
  </code></pre>