Example #1
0
 public void sendStuff()
 {
     while (running)
     {
         if (outQ.Count != 0)
         {
             Envelope check;
             if (outQ.TryPeek(out check) && check.isTcp) //Note: if udp message are not being send this could block up the TCP communicator.
             {
                 Envelope toSend;
                 if (outQ.TryDequeue(out toSend))
                 {
                     this.send(toSend);
                 }
             }
             else
             {
                 outQ.setQueueSignal(); //Marks send in someone else to get the message that was not meant for TCP.
                 Thread.Sleep(300);     //Wait a little for other communicator to pick it up.
             }
         }
         else
         {
             outQ.waitIncomingEnv(); //Waits for something to come into the queue
         }
     }
 }
 //Takes stuff off outQ and send it to where it should go.
 private void sendStuff()
 {
     while (running)
     {
         if (outQ.Count != 0)
         {
             Envelope check;
             if (outQ.TryPeek(out check) && !check.isTcp) //Note: This will cause the UDPcommunicator to become backed up if the TCP communicator is not taking things off this queue.
             {
                 Envelope toSend;
                 if (outQ.TryDequeue(out toSend))
                 {
                     this.send(toSend);
                 }
             }
             else
             {
                 outQ.setQueueSignal(); //Sets the queue again stating that nothing was taken out.
                 Thread.Sleep(100);     //Wait a little for other communicator to pick it up.
             }
         }
         else
         {
             outQ.waitIncomingEnv(); //Waits for something to enter the inQ.
         }
     }
 }
Example #3
0
 public void DoStuff()
 {
     while (running)
     {
         if (!inQueue.IsEmpty)
         {
             Envelope f;
             if (inQueue.TryDequeue(out f))
             {
                 ProcessEnvelope(f);
             }
             else
             {
                 Logger.Error("Dispatcher failed to Dequeue Envelope from Incoming Queue.");
             }
         }
         else
         {
             //Thread.Sleep(20);
             inQueue.waitIncomingEnv();
         }
     }
     t.Join();
 }