Пример #1
0
        private static void ParallelWorkingTest()
        {
            var servNoConfig = new MyServiceClient();
            var watch        = new Stopwatch();

            watch.Start();
            Parallel.For(0, 5, (i, loop) =>
            {
                var dowork = servNoConfig.DoLongWork10Second(2, 9);

                if (dowork != 11)
                {
                    Console.WriteLine(dowork + " " + i);
                }
                else
                {
                    Console.WriteLine($"{i} завершился успешно");
                }
            });

            watch.Stop();
            Console.WriteLine(watch.Elapsed.Seconds + "секунд");
        }