Пример #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;
        }