12345678910111213141516171819202122232425 |
- using InABox.Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PRS.Shared.Database_Update_Scripts.Utils;
- internal static class Utils
- {
- public static void ProcessInChunks<T>(IList<T> items, Action<IList<T>> processChunk, int stepBy, Action<double> reportPercentage)
- {
- for(int i = 0; i < items.Count; i += 1000)
- {
- reportPercentage((double)i / (double)items.Count * 100.0);
- var mpStages = new List<T>(1000);
- for(int j = i; j < Math.Min(i + 1000, items.Count); j++)
- {
- mpStages.Add(items[j]);
- }
- processChunk(mpStages);
- }
- }
- }
|