예제 #1
0
파일: TaskWorker.cs 프로젝트: supermax/TMS
        protected override IEnumerator Do()
        {
            while (!ExitEvent.InterWaitOne(0))
            {
                if (Dispatcher.ProcessNextTask())
                {
                    continue;
                }

                TaskDistributor.FillTasks(Dispatcher);

                if (Dispatcher.TaskCount != 0)
                {
                    continue;
                }

                var result = WaitHandle.WaitAny(new[] { ExitEvent, TaskDistributor.NewDataWaitHandle });
                if (result == 0)
                {
                    return(null);
                }

                TaskDistributor.FillTasks(Dispatcher);
            }
            return(null);
        }
예제 #2
0
파일: TickThread.cs 프로젝트: supermax/TMS
        /// <summary>
        ///     Does this instance.
        /// </summary>
        /// <returns></returns>
        protected override IEnumerator Do()
        {
            while (!ExitEvent.InterWaitOne(0))
            {
                _action();

                var result = WaitHandle.WaitAny(new WaitHandle[] { ExitEvent, _tickEvent }, _tickLengthInMilliseconds);
                if (result == 0)
                {
                    return(null);
                }
            }
            return(null);
        }