Пример #1
0
        public new void Dispose()
        {
            if (!IsDisposed())
            {
                SendPacket packet = mPacket;
                mPacket = null;

                SendDelivery delivery = mDelivery;
                mDelivery = null;

                Sender sender = mSender;
                mSender = null;

                if (packet != null && delivery != null)
                {
                    if (mCursor < mTotal)
                    {
                        packet.EndPacket();
                        packet.SetSuccess(false);
                        delivery.PostSendProgress(packet, 1);
                    }
                }

                if (sender != null)
                {
                    sender.Dispose();
                }
                try
                {
                    SetBuffer(null, 0, 0);
                }
                catch (Exception) { }

                // Clear
                while (mQueue.TryDequeue(out packet))
                {
                }

                base.Dispose();
            }
        }
Пример #2
0
        /// <summary>
        /// Send next packet
        /// </summary>
        private void SendNext()
        {
            SendPacket packet = mPacket;

            mPacket = null;
            // Notify
            if (packet != null)
            {
                // Set Status
                mStatus = mCursor == mTotal;

                // End
                packet.SetSuccess(mStatus);
                packet.EndPacket();

                // Post End
                mCursor = mTotal;
                NotifyProgress();
            }

            // Take a request from the queue.
            mSending = mQueue.TryDequeue(out packet);

            if (mSending && packet != null)
            {
                // Cancel
                if (packet.IsCanceled())
                {
                    SendNext();
                }
                else
                {
                    // Set Packet
                    mPacket = packet;

                    // Start Send
                    SendHead();
                }
            }
        }