Exemple #1
0
        protected virtual void OnProcessInitialized(QueuerProcessEventArgs <T> e)
        {
            this.IsProcessing = true;

            EventHandler <QueuerProcessEventArgs <T> > handler = this.ProcessInitialized;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        internal void Process(QueuerHandler <T> handler)
        {
            var state = new QueuerState <T>(handler);
            var args  = new QueuerProcessEventArgs <T>(state);

            this.OnProcessInitialized(args);

            for (int i = 0; i < this.ParallelTaskCount; i++)
            {
                this.Process_ExecuteAsync(state, i);
            }
        }
Exemple #3
0
        internal void Process(QueuerHandler <T> handler, IEnumerable <T> items)
        {
            var state = new QueuerState <T>(handler, items);
            var args  = new QueuerProcessEventArgs <T>(state);
            var count = Math.Min(this.ParallelTaskCount, items.Count());

            this.OnProcessInitialized(args);

            for (int i = 0; i < count; i++)
            {
                this.Process_ExecuteAsync(state, i);
            }
        }
Exemple #4
0
        protected virtual void OnProcessFinalized(object obj)
        {
            lock (this._taskProcessingLock)
            {
                if (this.HasQueuedItems && this.AreItemsProcessed)
                {
                    this.Item_ProcessReset();

                    var stopTime = DateTime.Now;
                    var e        = new QueuerProcessEventArgs <T>((QueuerState <T>)(obj), stopTime);

                    EventHandler <QueuerProcessEventArgs <T> > handler = this.ProcessFinalized;
                    if (handler != null)
                    {
                        handler(this, e);
                    }
                }
            }
        }