private void ContinousThreadLoop()
        {
            while (_run)
            {
                var cpy = taskScheduler.Tasks.Where(c => !c.IsFinished && !c.IsCancelled).ToList(); // we need a copy because the task list may be modified at runtime

                foreach (IScheduledTask task in cpy)
                {
                    if (task.Period == null || (task.Period != null && (task.ExecutionTarget != ExecutionTargetContext.Async && task.ExecutionTarget != ExecutionTargetContext.Sync)))
                    {
                        if (task.ExecutionTarget != ExecutionTargetContext.EveryAsyncFrame && task.ExecutionTarget != ExecutionTargetContext.EveryFrame)
                        {
                            continue;
                        }
                    }

                    taskScheduler.RunTask(task);
                }

                foreach (IScheduledTask task in cpy)
                {
                    if (task.ExecutionTarget != ExecutionTargetContext.NextAsyncFrame && task.ExecutionTarget != ExecutionTargetContext.NextFrame &&
                        task.ExecutionTarget != ExecutionTargetContext.Async && task.ExecutionTarget != ExecutionTargetContext.Sync)
                    {
                        continue;
                    }

                    taskScheduler.RunTask(task);
                }

                if (cpy.Count == 0)
                {
                    EventWaitHandle.WaitOne();
                }

                Thread.Sleep(20);
            }
        }
Exemple #2
0
        private void ContinousThreadLoop()
        {
            while (true)
            {
                var cpy = scheduler.Tasks.ToList(); // we need a copy because the task list may be modified at runtime

                foreach (ITask task in cpy.Where(c => !c.IsFinished && !c.IsCancelled))
                {
                    if (task.Period == null)
                    {
                        if (task.ExecutionTarget != ExecutionTargetContext.EveryAsyncFrame &&
                            task.ExecutionTarget != ExecutionTargetContext.EveryFrame &&
                            task.ExecutionTarget != ExecutionTargetContext.EveryPhysicsUpdate)
                        {
                            continue;
                        }
                    }

                    scheduler.RunTask(task);
                }

                Thread.Sleep(20);
            }
        }