示例#1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            CallbackTimer timer = (CallbackTimer)sender;

            if (timer == null || !timer.Enabled)
            {
                return;
            }

            timer.Callback.Invoke();
        }
示例#2
0
        internal void RegisterTimedCallback(Tuple <int, int, int> time, Action callback, out int handle)
        {
            int           seconds = (time.Item1 * 60 * 60) + (time.Item2 * 60) + time.Item3;
            CallbackTimer t       = new CallbackTimer(seconds * 1000, callback);

            t.Elapsed += Timer_Elapsed;

            //Get the first null index, or append to the list if there isn't one
            handle = Timers.IndexOf(null);
            if (handle == -1)
            {
                handle = Timers.Count;
                Timers.Add(t);
            }
            else
            {
                Timers[handle] = t;
            }

            t.Start();
        }
示例#3
0
		internal void RegisterTimedCallback(Tuple<int, int, int> time, Action callback, out int handle)
		{
			int seconds = (time.Item1 * 60 * 60) + (time.Item2 * 60) + time.Item3;
			CallbackTimer t = new CallbackTimer(seconds * 1000, callback);
			t.Elapsed += Timer_Elapsed;

			//Get the first null index, or append to the list if there isn't one
			handle = Timers.IndexOf(null);
			if (handle == -1)
			{
				handle = Timers.Count;
				Timers.Add(t);
			}
			else
			{
				Timers[handle] = t;
			}

			t.Start();
		}