示例#1
0
        private static void KillTimerId()
        {
            if (TickerFactory.timerId == 0U)
            {
                return;
            }
            int num = (int)TickerFactory.timeKillEvent(TickerFactory.timerId);

            TickerFactory.timerId = 0U;
        }
示例#2
0
 public static void DeleteAllCreatedTicker()
 {
     lock (TickerFactory.extAccess)
     {
         TickerFactory.KillTimerId();
         if (TickerFactory.TickerList == null)
         {
             return;
         }
         TickerFactory.TickerList.Clear();
     }
 }
示例#3
0
 private static void RemoveTicker(List <PhoenixContact.Common.Ticker.Ticker> remove)
 {
     foreach (PhoenixContact.Common.Ticker.Ticker ticker in remove)
     {
         TickerFactory.TickerList.Remove(ticker);
     }
     if (TickerFactory.TickerList.Count > 0)
     {
         return;
     }
     TickerFactory.KillTimerId();
     Thread.Sleep(Convert.ToInt32(TickerFactory.MainTick * 4));
 }
示例#4
0
 public static PhoenixContact.Common.Ticker.Ticker Create(string name, int intervall, ThreadPriority priority)
 {
     lock (TickerFactory.extAccess)
     {
         PhoenixContact.Common.Ticker.Ticker ticker = new PhoenixContact.Common.Ticker.Ticker(name, intervall, priority);
         TickerFactory.TickerList.Add(ticker);
         if (TickerFactory.timerId == 0U && TickerFactory.TickerList.Count > 0)
         {
             TickerFactory.timeProcPeriodic = new TickerFactory.TimeProc(TickerFactory.OnTimerPeriodicEvent);
             TickerFactory.timerId          = TickerFactory.timeSetEvent((uint)TickerFactory.MainTick, 0U, TickerFactory.timeProcPeriodic, 0U, 1U);
         }
         return(ticker);
     }
 }
示例#5
0
 private static void OnTimerPeriodicEvent(uint id, uint msg, uint user, uint param1, uint param2)
 {
     lock (TickerFactory.extAccess)
     {
         List <PhoenixContact.Common.Ticker.Ticker> remove = (List <PhoenixContact.Common.Ticker.Ticker>)null;
         foreach (PhoenixContact.Common.Ticker.Ticker ticker in TickerFactory.TickerList)
         {
             if (ticker.Remove)
             {
                 if (remove == null)
                 {
                     remove = new List <PhoenixContact.Common.Ticker.Ticker>();
                 }
                 remove.Add(ticker);
             }
             else
             {
                 ticker.Update(TickerFactory.tickCount);
             }
         }
         if (TickerFactory.tickCount < int.MaxValue)
         {
             TickerFactory.tickCount += TickerFactory.MainTick;
         }
         else
         {
             TickerFactory.tickCount = 0;
         }
         if (remove != null)
         {
             TickerFactory.RemoveTicker(remove);
         }
         if (TickerFactory.garbageCollectionTick <= 0 || TickerFactory.TickerList.Count <= 0 || TickerFactory.tickCount % TickerFactory.garbageCollectionTick != 0)
         {
             return;
         }
         GC.Collect();
     }
 }