示例#1
0
        private void BeginExecuteCallBack(IAsyncResult result)
        {
            AsynchronousPop3ResponseContext cx = (AsynchronousPop3ResponseContext)result.AsyncState;
            Boolean IsException = false;

            try
            {
                Int32 size = this._Stream.EndRead(result);
                if (cx.ReadBuffer(size) == true)
                {
                    this._Stream.BeginRead(cx.Buffer.Array, 0, cx.Buffer.Array.Length, this.BeginExecuteCallBack, cx);
                }
                else
                {
                    cx.OnEndGetResponse();
                    cx.Dispose();
                }
            }
            catch
            {
                IsException = true;
                throw;
            }
            finally
            {
                if (IsException == true && cx != null)
                {
                    cx.Dispose();
                }
            }
        }
示例#2
0
        public void BeginExecute(Pop3Command command, EndGetResponse callbackFunction)
        {
            AsynchronousContext cx = null;
            Boolean             IsResponseMultiLine = false;
            Boolean             IsException         = false;

            if (command is Top ||
                command is Retr ||
                command is List ||
                command is Uidl)
            {
                IsResponseMultiLine = true;
            }
            try
            {
                cx = new AsynchronousPop3ResponseContext(_ResponseEncoding, IsResponseMultiLine, callbackFunction);
                this.SendCommand(command.GetCommandString());
                this._Stream.BeginRead(cx.Buffer.Array, 0, cx.Buffer.Array.Length, this.BeginExecuteCallBack, cx);
            }
            catch
            {
                IsException = true;
                throw;
            }
            finally
            {
                if (IsException == true && cx != null)
                {
                    cx.Dispose();
                }
            }
        }