Exemplo n.º 1
0
		public void Start(ITimerItem item)
		{
			Timer key = new Timer();
			key.AutoReset = false;
			key.Interval = item.Interval;
			key.SynchronizingObject = item.SynchronizingObject;
			key.Elapsed += new ElapsedEventHandler(this.OnElapsed);
			lock (this.items)
				this.items.Add(key, item);
			key.Start();
		}
Exemplo n.º 2
0
        public void Start(ITimerItem item)
        {
            Timer key = new Timer();

            key.AutoReset           = false;
            key.Interval            = item.Interval;
            key.SynchronizingObject = item.SynchronizingObject;
            key.Elapsed            += new ElapsedEventHandler(this.OnElapsed);
            lock (this.items)
                this.items.Add(key, item);
            key.Start();
        }
Exemplo n.º 3
0
		public void Stop(ITimerItem item)
		{
			lock (this.items)
			{
				foreach (KeyValuePair<Timer, ITimerItem> item_0 in this.items)
				{
					if (item_0.Value == item)
					{
						this.items.Remove(item_0.Key);
						break;
					}
				}
			}
		}
Exemplo n.º 4
0
 public void Stop(ITimerItem item)
 {
     lock (this.items)
     {
         foreach (KeyValuePair <Timer, ITimerItem> item_0 in this.items)
         {
             if (item_0.Value == item)
             {
                 this.items.Remove(item_0.Key);
                 break;
             }
         }
     }
 }
Exemplo n.º 5
0
Arquivo: Timer.cs Projeto: zjbsean/TM
        protected static void Add(ITimerItem titem)
        {
            //按时间倒序
            bool isInsert = false;

            for (int i = 0; i < m_timerItemList.Count; i++)
            {
                if (titem.NextTime <= m_timerItemList[i].NextTime)
                {
                    m_timerItemList.Insert(i, titem);
                    isInsert = true;
                    break;
                }
            }
            if (!isInsert)
            {
                m_timerItemList.Add(titem);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Returns true if last of event of timer is cancelled event.
 /// </summary>
 /// <param name="timerItem"></param>
 /// <returns></returns>
 public static bool IsCancelled(this ITimerItem timerItem) => timerItem.LastEvent() is TimerCancelledEvent;
Exemplo n.º 7
0
 /// <summary>
 /// Returns true if last event of timer is fired event.
 /// </summary>
 /// <param name="timerItem"></param>
 /// <returns></returns>
 public static bool IsFired(this ITimerItem timerItem) => timerItem.LastEvent() is TimerFiredEvent;