コード例 #1
0
ファイル: Timer.cs プロジェクト: Dyno1990/TelerikAcademy-1
 public static void DoStuffEveryTTicks(int t, TimerDel importantMethod)
 {
     if (sw.ElapsedTicks > t)
     {
         importantMethod();
         sw.Restart();
     }
 }
コード例 #2
0
 public static void DoIteEachTSeconds(int t, TimerDel someMethod)
 {
     if (measure.ElapsedTicks > t*1000000)
             {
                 someMethod();
                 measure.Restart();
             }
 }
コード例 #3
0
 public static void DoStuffEveryTTicks(int t, TimerDel importantMethod)
 {
     if (sw.ElapsedTicks > t)
     {
         importantMethod();
         sw.Restart();
     }
 }
コード例 #4
0
ファイル: GameInfoView.cs プロジェクト: d-sage/Tetris
        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;
        }
コード例 #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);
        }