예제 #1
0
    public EventQueue()
    {
        eventQueue = new ConcurrentQueue <IEventBase>();

        RepeatingEvent cleanEvents = new RepeatingEvent(CleanRepeatingEvents, -1, 0, 30000);

        // Timers need a reference to Do, so need to have access to this scope
        cleanEvents.timer = new HighPrecisionTimer(delegate(System.Object obj){ RepeatingEvent evnt = (RepeatingEvent)obj;
                                                                                if (!evnt.flag.IsSet)
                                                                                {
                                                                                    Do(evnt);
                                                                                }
                                                   },
                                                   cleanEvents, cleanEvents.delay, cleanEvents.interval);

        if (!repeatingEvents.TryAdd(repeatingEventID, cleanEvents))
        {
            throw new Exception("Could not add repeating event to queue");
        }
    }
예제 #2
0
 // enqueues repeating event at set intervals. If timer isn't
 // stopped, stopping processing thread will still stop execution
 // of events
 public virtual void DoRepeating(RepeatingEvent thisEvent)
 {
     // timers should only be created if running
     if (Running())
     {
         thisEvent.timer = new HighPrecisionTimer(delegate(System.Object obj){ RepeatingEvent evnt = (RepeatingEvent)obj;
                                                                               if (!evnt.flag.IsSet)
                                                                               {
                                                                                   Do(evnt);
                                                                               }
                                                  },
                                                  thisEvent, thisEvent.delay, thisEvent.interval);
         repeatingEventID++;
         if (!repeatingEvents.TryAdd(repeatingEventID, thisEvent))
         {
             throw new Exception("Could not add repeating event to queue");
         }
     }
     else
     {
         throw new Exception("Can't enqueue to non running Queue");
     }
 }
예제 #3
0
 public override void DoRepeating(RepeatingEvent thisEvent)
 {
     mainEvents.DoRepeating(thisEvent);
 }
예제 #4
0
 public abstract void DoRepeating(RepeatingEvent thisEvent);