예제 #1
0
        public CWorkItem <T> QueueWorkItem <T>(Func <T> act, EventHandler <StatusChangeEventArgs> onStatusChange = null)
        {
            CWorkItem <T> item = new CWorkItem <T> {
                StartTime = DateTime.Now,
                Action    = act,
                Status    = CTaskStatus.WaitingToRun
            };

            item.StatusChange = onStatusChange;
            this._waitingTasks.Enqueue(item);
            this.NotifyThreadPoolOfPendingWork();
            if (this._nowRunningCount > this._largestPoolSize)
            {
                this._largestPoolSize = this._nowRunningCount;
            }
            return(item);
        }
예제 #2
0
        public CWorkItem <T> QueueWorkItem <T>(Func <T> act, EventHandler <StatusChangeEventArgs> onStatusChange = null)
        {
            var task = new CWorkItem <T>
            {
                StartTime = DateTime.Now,
                Action    = act,
                Status    = CTaskStatus.WaitingToRun
            };

            task.StatusChange = onStatusChange;

            _waitingTasks.Enqueue(task);

            NotifyThreadPoolOfPendingWork();

            if (_nowRunningCount > _largestPoolSize)
            {
                _largestPoolSize = _nowRunningCount;
            }

            return(task);
        }