Abc.NCrafts.Quizz.Performance.Questions._009.Answer1.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            const int partitionCount = 5;

            var results = new int[partitionCount];

            // begin
            Parallel.For(0, partitionCount, i =>
            {
                for (var index = i; index < _values.Length; index += partitionCount)
                {
                    results[i] += _values[index];
                }
            });

            var max = results.Sum();
            // end

            Logger.Log("Max: {0}", max);
        }
    }