Exemplo n.º 1
0
        private void Run()
        {
            try
            {
                if (Connect())
                {
                    SendLoop();
                }
            }
            catch (Exception e)
            {
                scheduler.ReportException(e, "sending to " + EndpointDescription());
            }

            scheduler.UnregisterSender(destinationPublicKey, this);

            // If we crashed in the middle of sending a packet, re-queue it
            // for sending by another sender thread.

            if (currentSendTask != null)
            {
                scheduler.ResendPacket(currentSendTask);
                currentSendTask = null;
            }

            // If there are packets queued for us to send, re-queue them
            // for sending by another sender thread.

            while (sendQueue.TryReceive(out currentSendTask))
            {
                scheduler.ResendPacket(currentSendTask);
                currentSendTask = null;
            }
        }