Represents a time
示例#1
0
        private void InitThread(Time time, Exp action)
        {
            while (true)
            {
                Thread.Sleep(GetTimeUntilSleep(time));

                action.Invoke();
            }
        }
示例#2
0
        public void Schedule(Exp exp, Time time)
        {
            actions.Add(exp);

            Thread t = new Thread(new ThreadStart(() => { InitThread(time, exp); }));

            workers.Add(t);

            t.Start();
        }
示例#3
0
        private TimeSpan GetTimeUntilSleep(Time time)
        {

            DateTime execDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, time.Hours, time.Minutes, time.Seconds);

            if (DateTime.Now > execDate)
                execDate = execDate.AddDays(1);

            TimeSpan result = execDate - DateTime.Now;

            return result;
        }