Beispiel #1
0
 private void Initialize(IPriortyQueue <MessageInfo <TMessage> > messageQueue)
 {
     if (messageQueue != null)
     {
         schedule = new MessageSchedule <TMessage>(messageQueue, this);
     }
 }
Beispiel #2
0
 public void Dispose()
 {
     if (thread != null)
     {
         IsRuning = false;
         Thread.Sleep(MillisecondsTimeout);
         thread = null;
     }
     if (MessageQueue != null)
     {
         MessageQueue.Clear();
         MessageQueue = null;
     }
 }
Beispiel #3
0
        public MessageSchedule(IPriortyQueue <MessageInfo <TMessage> > queue, IMessageRouter host)
        {
            if (!queue.IsSynchronized)
            {
                MessageQueue = PriorityQueue <MessageInfo <TMessage> > .Synchronized(queue);
            }
            else
            {
                MessageQueue = queue;
            }

            thread = new Thread(delegate()
            {
                IsRuning = true;
                MessageInfo <TMessage> item = null;
                while (true)
                {
                    if (!IsRuning)
                    {
                        return;
                    }

                    while (MessageQueue.Count > 0)
                    {
                        //Thread.Sleep(MillisecondsTimeout);
                        if ((item = MessageQueue.Pop()) != null)
                        {
                            host.Send(item.Sender, item.Message, true);
                        }
                        Thread.Sleep(MillisecondsTimeout);
                    }
                }
            });
            thread.IsBackground = true;
            thread.Name         = "MessageManager.MessageQueue.Thread";
            thread.Start();
        }
Beispiel #4
0
 public PriortyMessageRouter(IPriortyQueue <MessageInfo <TMessage> > messageQueue)
 {
     Initialize(messageQueue);
 }
Beispiel #5
0
 public static IPriortyQueue <T> Synchronized(IPriortyQueue <T> innerQueue)
 {
     return(new SynPriorityQueue(innerQueue));
 }
Beispiel #6
0
 public SynPriorityQueue(IPriortyQueue <T> queue)
 {
     this.InnerQueue = queue;
 }