Esempio n. 1
0
        public CTask <T> QueueWorkItem <T>(Func <T, int> act)
        {
            var task = new CTask <T>
            {
                StartTime = DateTime.Now,
                Action    = act,
                Status    = CTaskStatus.NotStart
            };

            _waitingTasks.Enqueue(task);
            NotifyThreadPoolOfPendingWork();
            return(task);
        }
Esempio n. 2
0
        public List <CTask <T> > QueueWorkItem <T>(IEnumerable <Func <T, int> > acts)
        {
            var tasks = new List <CTask <T> >();

            foreach (var act in acts.ToArray())
            {
                var task = new CTask <T>
                {
                    StartTime = DateTime.Now,
                    Action    = act,
                    Status    = CTaskStatus.NotStart
                };
                _waitingTasks.Enqueue(task);
            }

            NotifyThreadPoolOfPendingWork();
            return(tasks);
        }