예제 #1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Timer()
        {
            timer = StaticExtensionEventInterfaces.TimerEventFactory.NewTimer;
            Action act = Event;

            locked = act.LockedAction();
        }
예제 #2
0
 /// <summary>
 /// Creates a form for component properties editor
 /// </summary>
 /// <param name="component">The component</param>
 /// <returns>The result form</returns>
 public override object CreateForm(INamedComponent component)
 {
     if (component is IObjectLabel)
     {
         IObjectLabel lab = component as IObjectLabel;
         // The object of component
         ICategoryObject obj = lab.Object;
         if (obj is ITimerEvent)
         {
             ITimerEvent timer = obj as ITimerEvent;
             return(new Forms.FormTimer(obj as ITimerEvent));
         }
     }
     return(null);
 }
예제 #3
0
        public void addEventListeners(ITimerEvent item)
        {
            int idx = _toRemove.IndexOf(item);

            if (idx != -1)
            {
                _toRemove.RemoveAt(idx);
            }

            if (this.listeners.Contains(item))
            {
                return;
            }

            this.listeners.Add(item);
        }
예제 #4
0
파일: PollerBase.cs 프로젝트: zad15c/netmq
        /// <summary>
        /// Cancel the timer that was created with the given sink object with the given Id.
        /// </summary>
        /// <param name="sink">the ITimerEvent that the timer was created with</param>
        /// <param name="id">the Id of the timer to cancel</param>
        /// <remarks>
        /// The complexity of this operation is O(n). We assume it is rarely used.
        /// </remarks>
        public void CancelTimer([NotNull] ITimerEvent sink, int id)
        {
            bool removed = false;

            foreach (var pair in m_timers)
            {
                var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink);

                if (timer != null)
                {
                    removed = pair.Value.Remove(timer);
                    break;
                }
            }

            Debug.Assert(removed);
        }
예제 #5
0
        //  Cancel the timer created by sink_ object with ID equal to id_.
        public void CancelTimer(ITimerEvent sink, int id)
        {
            //  Complexity of this operation is O(n). We assume it is rarely used.
            var foundTimers = new Dictionary <long, TimerInfo>();

            foreach (var pair in m_timers)
            {
                var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink);

                if (timer == null)
                {
                    continue;
                }

                if (!foundTimers.ContainsKey(pair.Key))
                {
                    foundTimers[pair.Key] = timer;
                    break;
                }
            }

            if (foundTimers.Count > 0)
            {
                foreach (var foundTimer in foundTimers)
                {
                    if (m_timers[foundTimer.Key].Count == 1)
                    {
                        m_timers.Remove(foundTimer.Key);
                    }
                    else
                    {
                        m_timers[foundTimer.Key].Remove(foundTimer.Value);
                    }
                }
            }
            else
            {
                //  Timer not found.
                Debug.Assert(false);
            }
        }
예제 #6
0
        /// <summary>
        ///     Cancel the timer that was created with the given sink object with the given Id.
        /// </summary>
        /// <param name="sink">the ITimerEvent that the timer was created with</param>
        /// <param name="id">the Id of the timer to cancel</param>
        /// <remarks>
        ///     The complexity of this operation is O(n). We assume it is rarely used.
        /// </remarks>
        public void CancelTimer([NotNull] ITimerEvent sink, int id)
        {
            Dictionary <long, TimerInfo> foundTimers = new Dictionary <long, TimerInfo>();

            foreach (KeyValuePair <long, List <TimerInfo> > pair in this.m_timers)
            {
                TimerInfo timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink);

                if (timer == null)
                {
                    continue;
                }

                if (!foundTimers.ContainsKey(pair.Key))
                {
                    foundTimers[pair.Key] = timer;
                    break;
                }
            }

            if (foundTimers.Count > 0)
            {
                foreach (KeyValuePair <long, TimerInfo> foundTimer in foundTimers)
                {
                    if (this.m_timers[foundTimer.Key].Count == 1)
                    {
                        this.m_timers.Remove(foundTimer.Key);
                    }
                    else
                    {
                        this.m_timers[foundTimer.Key].Remove(foundTimer.Value);
                    }
                }
            }
            else
            {
                // Timer not found.
                Debug.Assert(false);
            }
        }
예제 #7
0
 public TimerInfo(ITimerEvent sink, int id)
 {
     Sink = sink;
     Id   = id;
 }
예제 #8
0
파일: PollerBase.cs 프로젝트: zls3201/netmq
 /// <summary>
 /// Create a new TimerInfo object from the given sink and id.
 /// </summary>
 /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param>
 /// <param name="id">an integer id that identifies this timer</param>
 public TimerInfo([NotNull] ITimerEvent sink, int id)
 {
     Sink = sink;
     Id   = id;
 }
예제 #9
0
파일: PollerBase.cs 프로젝트: awb99/netmq
 /// <summary>
 /// Create a new TimerInfo object from the given sink and id.
 /// </summary>
 /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param>
 /// <param name="id">an integer id that identifies this timer</param>
 public TimerInfo( ITimerEvent sink, int id)
 {
     Sink = sink;
     Id = id;
 }
예제 #10
0
파일: PollerBase.cs 프로젝트: awb99/netmq
        /// <summary>
        /// Cancel the timer that was created with the given sink object with the given Id.
        /// </summary>
        /// <param name="sink">the ITimerEvent that the timer was created with</param>
        /// <param name="id">the Id of the timer to cancel</param>
        /// <remarks>
        /// The complexity of this operation is O(n). We assume it is rarely used.
        /// </remarks>
        public void CancelTimer( ITimerEvent sink, int id)
        {
            var foundTimers = new Dictionary<long, TimerInfo>();

            foreach (var pair in m_timers)
            {
                var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink);

                if (timer == null)
                    continue;

                if (!foundTimers.ContainsKey(pair.Key))
                {
                    foundTimers[pair.Key] = timer;
                    break;
                }
            }

            if (foundTimers.Count > 0)
            {
                foreach (var foundTimer in foundTimers)
                {
                    if (m_timers[foundTimer.Key].Count == 1)
                    {
                        m_timers.Remove(foundTimer.Key);
                    }
                    else
                    {
                        m_timers[foundTimer.Key].Remove(foundTimer.Value);
                    }
                }
            }
            else
            {
                // Timer not found.
                Debug.Assert(false);
            }
        }
예제 #11
0
 public void removeEventListeners(ITimerEvent item)
 {
     _toRemove.Add(item);
 }
예제 #12
0
 internal FormTimer(ITimerEvent timer) :
     this()
 {
     this.timer             = timer;
     userControlTimer.Timer = timer;
 }
예제 #13
0
 public TimerEventViewModel(IEventAggregator aggregator, ILocalizationHelper loc, ITimerEvent timerEvent) : base(aggregator, loc, timerEvent)
 {
     _eventAggregator = aggregator;
     DisplayName      = loc.GetByKey("TimerEvent");
     Model            = timerEvent;
 }
예제 #14
0
 /// <summary>
 ///     Create a new TimerInfo object from the given sink and id.
 /// </summary>
 /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param>
 /// <param name="id">an integer id that identifies this timer</param>
 public TimerInfo([NotNull] ITimerEvent sink, int id)
 {
     this.Sink = sink;
     this.Id   = id;
 }