예제 #1
0
        private async Task <long> GetOutputFor(long[] phaseSettings)
        {
            var outputA = new BlockingCollection <long>();
            var outputB = new BlockingCollection <long>();
            var outputC = new BlockingCollection <long>();
            var outputD = new BlockingCollection <long>();
            var outputE = new BlockingCollection <long>();


            outputA.Add(phaseSettings[1]);
            outputB.Add(phaseSettings[2]);
            outputC.Add(phaseSettings[3]);
            outputD.Add(phaseSettings[4]);
            outputE.Add(phaseSettings[0]);
            outputE.Add(0);

            var A = RunComputerWithWiredIO(phaseSettings[0], outputE, outputA);
            var B = RunComputerWithWiredIO(phaseSettings[1], outputA, outputB);
            var C = RunComputerWithWiredIO(phaseSettings[2], outputB, outputC);
            var D = RunComputerWithWiredIO(phaseSettings[3], outputC, outputD);
            var E = RunComputerWithWiredIO(phaseSettings[4], outputD, outputE);

            await Task.WhenAll(A, B, C, D, E);

            return(outputE.LastOrDefault());
        }