Esempio n. 1
0
        void ThreadProc()
        {
            TimeSpan minSleep = new TimeSpan(0, 0, 0, 0, 250);
            TimeSpan sleep    = minSleep;

            while (!m_shutdown)
            {
                if (sleep < minSleep)
                {
                    sleep = minSleep;
                }

                m_event.WaitOne(sleep);

                TaskKey next = Next(out sleep);
                if (next == null)
                {
                    continue;
                }

                next.Call();
                AddInternal(next);
                sleep.Add(minSleep);
            }

            lock (m_sync)
                foreach (var task in m_tasks)
                {
                    task.Key.Call();
                }
        }
Esempio n. 2
0
        private void AddInternal(TaskKey task)
        {
            if (task == null)
            {
                return;
            }

            lock (m_sync)
                m_tasks.Add(task, task);
        }