Ejemplo n.º 1
0
        public void CheckBatchProgress(object sender, BatchCompletedEventArgs frea)
        {
            _completed++;

            if (_completed == Batches.Count)
            {
                OnDone(this, new EventArgs());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Main method - run the batch
        /// </summary>
        /// <returns></returns>
        public async Task Run()
        {
            foreach (object item in Items)
            {
                // Await all file reads
                object result = await BatchSingle(item);

                // Check completion
                Completed++;

                BatchCompletedEventArgs frea = new BatchCompletedEventArgs()
                {
                    Result = result
                };
                OnProcessComplete?.Invoke(this, frea);

                if (Completed == Amount)
                {
                    frea = new BatchCompletedEventArgs();
                    OnBatchComplete?.Invoke(this, frea);
                }
            }
        }