Exemplo n.º 1
0
        private static void Main()
        {
            Console.WriteLine("Для запуска нажмите любую клавишу");
            Console.ReadKey();

            ThreadPoolWorker <int> threadPoolWorker = new ThreadPoolWorker <int>(SumNumber);

            threadPoolWorker.Start(1000);

            while (threadPoolWorker.Completed == false)
            {
                Console.Write("*");
                Thread.Sleep(35);
            }


            //for (int i = 0; i < 5; i++)
            //{
            //    Console.Write("*");
            //    Thread.Sleep(35);
            //}

            Console.WriteLine();
            Console.WriteLine($"Результат асинхронной операции = {threadPoolWorker.Result:N}");


            for (int i = 0; i < 20; i++)
            {
                Console.Write("*");
                Thread.Sleep(35);
            }
        }
Exemplo n.º 2
0
        private static void Main()
        {
            Console.WriteLine("Для запуска нажмите любую клавишу");
            Console.ReadKey();

            //  ThreadPoolWorker threadPoolWorker = new ThreadPoolWorker(new Action<object>(StarWriter));
            ThreadPoolWorker threadPoolWorker = new ThreadPoolWorker(StarWriter);

            threadPoolWorker.Start('*');

            for (int i = 0; i < 40; i++)
            {
                Console.Write('-');
                Thread.Sleep(50);
            }

            threadPoolWorker.Wait();

            Console.WriteLine($"Метод Main закончил свою работу.");
        }