• Ivy Seo

Parallel for each - much faster

This example code is pretty straightforward :

        public void Insert10000RandomData()
        {
            List<int> integerList = Enumerable.Range(1, 10).ToList();            // 1 - 10
            Parallel.ForEach(integerList, i =>
            {
                RunRows();
            });
        }
        public void RunRows()
        {
            int i = 0;
            while (i < 1000)
            {
                Console.WriteLine(i);
                i++;
            }
        }