title: Asynchronous callback "Async End called with an IAsyncResult from a different Begin method. Parameter name: result"
body: <p>I can't figure out why this is.</p>
  
  <p>I have a connect method that works fine:</p>
  
  <pre><code>public void Connect()
  {
      _client.BeginConnect(new AsyncCallback(this.ConnectCallback), _client);
  }
  
  public void ConnectCallback(IAsyncResult asyncResult)
  {
      ServerClient callback = null;
  
          callback = (ServerClient)asyncResult.AsyncState;
          callback.EndConnect(asyncResult);
  
          Program.IMMainForm.BeginInvoke(new frmMain.ConnectionEstablishedNotification(Program.IMMainForm.ConnectionEstablished));
  </code></pre>
  
  <p>This works totally fine. I pretty much copied and pasted this code for my Send method:</p>
  
  <pre><code>public void Send(string code, string data)
  {
      _client.BeginSendToServer((code + data), new AsyncCallback(this.SendCallback), _client);
  }
  
  
  public void SendCallback(IAsyncResult asyncResult)
  {
      ServerClient callback = null;
  
          callback = (ServerClient)asyncResult.AsyncState;
          callback.EndConnect(asyncResult);
  }
  </code></pre>
  
  <p>However it errors on the EndConnect line with the error</p>
  
  <p>"Async End called with an IAsyncResult from a different Begin method. 
  Parameter name: result" </p>
  
  <p>saying </p>
  
  <p>A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll</p>
  
  <p>I'm not 100% on async stuff so is there something obvious I am doing wrong?</p>