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

            try
            {
                stateObj.UpdateContext();
                DataStream.EndWrite(ar);

                if (_aborted)
                {
                    throw new FtpAbortedException();
                }

                if (stateObj.UserStream.AvailableSpace > 0)
                {
                    //read and send more data
                    stateObj.UserStream.BeginRead(_workBuffer,
                                                  0,
                                                  _workBuffer.Length,
                                                  new AsyncCallback(this.UserStreamRead_End),
                                                  stateObj);
                }
                else
                {
                    FinishTransferingStream(DataStream);
                    OnCompleted();
                    stateObj.SetCompleted();
                }
            }
            catch (Exception e)
            {
                stateObj.Exception = e;
                stateObj.SetCompleted();
            }
            catch
            {
                NSTrace.WriteLineError("Non-CLS exception at: " + Environment.StackTrace);
                throw;
            }
        }