Beispiel #1
0
 public static void DoStuffEveryTTicks(int t, TimerDel importantMethod)
 {
     if (sw.ElapsedTicks > t)
     {
         importantMethod();
         sw.Restart();
     }
 }
 public static void DoIteEachTSeconds(int t, TimerDel someMethod)
 {
     if (measure.ElapsedTicks > t*1000000)
             {
                 someMethod();
                 measure.Restart();
             }
 }
Beispiel #3
0
 public static void DoStuffEveryTTicks(int t, TimerDel importantMethod)
 {
     if (sw.ElapsedTicks > t)
     {
         importantMethod();
         sw.Restart();
     }
 }
Beispiel #4
0
        public GameInfoView(Game game, Rectangle view = new Rectangle())
        {
            _view = view;

            _nextBlock = new TNextBlockComponent();
            _score     = new TNumberComponent("Score");
            _lines     = new TNumberComponent("Lines");
            _level     = new TNumberComponent("Level");

            _level.detail = 1;

            timerNotifier = game.updateTimer;
            _mainForm     = game.MainForm;
        }
Beispiel #5
0
        /// <summary>
        /// 定时器事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            if (TimerEventList == null || TimerEventList.Count <= 0)
            {
                return;
            }

            var del = new TimerDel(delegate
            {
                try
                {
                    bool isMinute = DateTime.Now.Second == 0, isHour = DateTime.Now.Minute == 0;
                    Dictionary <TimerType, bool> listTimerType = new Dictionary <TimerType, bool>()
                    {
                        { TimerType.Second, true },
                        { TimerType.Minute, isMinute },
                        { TimerType.Hour, isHour }
                    };

                    lock (TimerEventList)
                    {
                        foreach (var tType in listTimerType)
                        {
                            if (HaveTimerEvent(tType.Key, TimerEventList) && tType.Value)
                            {
                                TimerElapsed(TimerEventList[tType.Key], sender, e);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            });

            del.BeginInvoke(null, null);
        }