コード例 #1
0
ファイル: MyTimer.cs プロジェクト: FraGio/SmartGardenOK
        public bool SetTimerPrincipale(DateTime date,TimeSpan intervallo,ElapsedEventHandler start)
        {
            TimeSpan data = date - DateTime.Now;
            _intervalloPrincipale = intervallo;
            /*
            #region deregistro
            foreach (MyInternalTimer timer in _timers.Values)
            {
                _timerPrincipale.RemoveEventHandler(timer.Start);
            }
            _timerPrincipale.RemoveEventHandler(SetNextIntervalloPrincipale);
            _timerPrincipale = new MyInternalTimer((long)data.TotalMilliseconds);
            #endregion

            #region registro
            //TODO non devo agganciare al timer principale i secondari ma li faccio partire immediatamente
            //quando il timer scatta (funzione scatto timer principale)
            foreach (MyInternalTimer timer in _timers.Values)
            {
                _timerPrincipale.AddEventHandler(timer.Start);
            }

            #endregion
            */
            _timerPrincipale = new MyInternalTimer((long)data.TotalMilliseconds);
            _timerPrincipale.AddEventHandler(start);
            _timerPrincipale.Start();
            _timerPrincipale.AddEventHandler(SetNextIntervalloPrincipale);
            return true;
        }
コード例 #2
0
ファイル: MyTimer.cs プロジェクト: FraGio/SmartGardenOK
        public bool SetTimer(TimeSpan data,ElapsedEventHandler ev)
        {
            if (!_timers.ContainsKey(data))
            {
                MyInternalTimer timerApertura = new MyInternalTimer((long)data.TotalMilliseconds+1);
                _timers.Add(data, timerApertura);
            }
            _timers[data].AddEventHandler(ev);
            _timers[data].Start();

            return true;
        }
コード例 #3
0
ファイル: MyTimer.cs プロジェクト: FraGio/SmartGardenOK
 private MyTimer()
 {
     _timerPrincipale = new MyInternalTimer(10000);
     _timers = new Dictionary<TimeSpan, MyInternalTimer>();
     _intervalloPrincipale = new TimeSpan(1, 0, 0, 0);
 }