Example #1
0
 private void ProcessQueue(object sender, Timers.ElapsedEventArgs e)
 {
     while (messageQueue.Count != 0)
     {
         Datagram msg = null;
         if (!messageQueue.TryPeek(out msg))
         {
             continue;
         }
         if (msg != null && (running || msg.Sticky))
         {
             msg.Send();
             if (msg.SendCount > DATAGRAMS_PER_MESSAGE)
             {
                 messageQueue.TryDequeue(out msg);
             }
             break;
         }
         else
         {
             messageQueue.TryDequeue(out msg);
         }
     }
     datagramPosted.Set();
     queueTimer.Enabled  = messageQueue.Count != 0;
     queueTimer.Interval = random.Next(50, running ? 300 : 100);
 }
Example #2
0
        private void SendDatagram(IPEndPoint endpoint, IPAddress address, string message, bool sticky)
        {
            if (!running)
            {
                return;
            }
            var dgram = new Datagram(endpoint, address, message, sticky);

            if (messageQueue.Count == 0)
            {
                dgram.Send();
            }
            messageQueue.Enqueue(dgram);
            queueTimer.Enabled = true;
        }
Example #3
0
 private void SendDatagram(IPEndPoint endpoint, IPAddress address,
                           string message, bool sticky)
 {
   if (!running) {
     return;
   }
   var dgram = new Datagram(endpoint, address, message, sticky);
   if (messageQueue.Count == 0) {
     dgram.Send();
   }
   messageQueue.Enqueue(dgram);
   queueTimer.Enabled = true;
 }