void ReadLastResponse_End(IAsyncResult ar) { RunDTP_SO stateObj = (RunDTP_SO)ar.AsyncState; try { stateObj.UpdateContext(); bool needMore = true; AsyncCallback callBack = null; FtpResponse response = _cc.EndReadResponse(ar); if (!response.IsPreliminaryReply) { needMore = false; //---------------------------------------- // Dealing with Abort or Reset // if (!_aborted && (null == stateObj.AbortEx)) { if (!stateObj.ManuallyClosed) { FtpClient.CheckCompletionResponse(response); } else { //---------------------------------------- //we DID close the data connection, //so, in general, the response should be //errorneous - therefore skip checking of it } } else { if (null != stateObj.AbortEx) // && //!response.IsCompletionReply) { stateObj.AbortEx.SetResponse(response); } stateObj.Exception = stateObj.AbortEx; //---------------------------------------- //If "ABOR" command was sent we need to //read one more response ... // if (_aborted) { callBack = new AsyncCallback(this.ReadAbortResponse_End); needMore = true; } } if (!_aborted && _quited) { callBack = new AsyncCallback(this.ReadQuitResponse_End); needMore = true; } } else { stateObj.PrelRespCount++; if (stateObj.PrelRespCount > 10) { throw GetTooManyRespException(); } } if (true == needMore) { if (null == callBack) { callBack = new AsyncCallback(this.ReadLastResponse_End); } //---------------------------------------- //read all preliminary results, till enough _cc.BeginReadResponse(stateObj.Timeout, callBack, stateObj); } else { ClearAtEnd(stateObj); } } catch (Exception e) { HandleCatch(e, stateObj); } catch { HandleCatch(null, stateObj); } }