Example #1
0
        void SendCmdEx_End(IAsyncResult ar)
        {
            Quit_SO stateObj = (Quit_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                //----------------------------------------
                //finish sending command
                FtpResponse response = _cc.EndSendCommandEx(ar);

                //----------------------------------------
                //Check response
                FtpClient.CheckCompletionResponse(response);
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
            }
            finally
            {
                //----------------------------------------
                //Unlock control connection
                _cc.Unlock();

                stateObj.SetCompleted();
            }
        }
Example #2
0
        void SendCmd_End(IAsyncResult ar)
        {
            Quit_SO stateObj = (Quit_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                //----------------------------------------
                //finish sending command
                _cc.EndSendCommand(ar);

                //----------------------------------------
                //Notify DTP that it should handle quit
                //issue
                _client.CurrentDTP.Quit();
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
            }
            finally
            {
                //----------------------------------------
                //Unlock control connection
                _cc.Unlock();

                stateObj.SetCompleted();
            }
        }
Example #3
0
        internal IAsyncResult BeginExecute(int timeout, AsyncCallback cb, object state)
        {
            Quit_SO stateObj = new Quit_SO(timeout, cb, state);

            //----------------------------------------
            //Lock Control connection.
            //
            _cc.BeginLock(Timeout.Infinite,
                          new WaitOrTimerCallback(Lock_End),
                          stateObj);

            return(stateObj);
        }
Example #4
0
        void Lock_End(object state, bool timedout)
        {
            Quit_SO stateObj = (Quit_SO)state;

            try
            {
                stateObj.UpdateContext();
                //----------------------------------------
                //Indicate that we lock CC
                stateObj.CCLocked = true;

                if (null != _client.CurrentDTP)
                {
                    //----------------------------------------
                    //In case when we have active DTP we delegate
                    //handling responses to it and here only send
                    //quit command
                    _cc.BeginSendCommand(stateObj.Timeout,
                                         "QUIT",
                                         new AsyncCallback(SendCmd_End),
                                         stateObj);
                }
                else
                {
                    //----------------------------------------
                    //In case there is no DTP, we should
                    //dealing with responses here ...
                    _cc.BeginSendCommandEx(stateObj.Timeout,
                                           "QUIT",
                                           new AsyncCallback(SendCmdEx_End),
                                           stateObj);
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
        }