Exemplo n.º 1
0
        void RunDTP_End(IAsyncResult ar)
        {
            PutFile_SO stateObj = (PutFile_SO)ar.AsyncState;

            try
            {
                stateObj.UpdateContext();
                _currentDTP.EndExecute(ar);
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
            }
            finally
            {
                _currentDTP.Dispose();
                _currentDTP = null;
                stateObj.SetCompleted();
            }
        }
Exemplo n.º 2
0
        internal IAsyncResult BeginExecute(int timeout,
                                           Stream userStream,
                                           string fileName,
                                           long length,
                                           AsyncCallback cb,
                                           object state)
        {
            PutFile_SO stateObj = null;

            SetProgress(true);
            try
            {
                CreateDTP();
                stateObj = new PutFile_SO(userStream,
                                          cb,
                                          state);

                string cmd = "STOR " + fileName;
                _currentDTP.BeginExecute(timeout,
                                         cmd,
                                         _client.DataType,
                                         -1,
                                         new DTPStreamCommon(userStream, DTPStreamType.ForReading, length),
                                         new AsyncCallback(this.RunDTP_End),
                                         stateObj);
            }
            catch (Exception e)
            {
                if (null != _currentDTP)
                {
                    _currentDTP.Dispose();
                    _currentDTP = null;
                }
                SetProgress(false);
                throw e;
            }
            return(stateObj);
        }