예제 #1
0
        static void Main(string[] args)
        {
            //var result = await AddAsync(1, 2);

            //DoSomething().Wait();

            Console.WriteLine("Press any Key to start.");
            Console.ReadKey();
            //Console.ReadLine();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            ParallelSamples sample = new ParallelSamples();

            // 1. Executes all tasks sequentianally
            //sample.StartSequenced(numThreads, workerFunction);

            // 2.  Executes with spaning of every worker on a single thread.
            //sample.StartMultithreadedNative(numThreads, workerFunction);

            // 3
            //sample.StartMultithreadedNativeV2(numThreads, workerFunction);

            // 4.
            sample.StartWithTpl(numThreads, workerFunction);

            sw.Stop();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("{0} ms", sw.ElapsedMilliseconds);

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press any Key to start.");
            Console.ReadKey();
            //Console.ReadLine();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            ParallelSamples nt = new ParallelSamples();

            // Executes all tasks sequentianally
            nt.StartSequenced(numThreads, workerFunction);

            // Executes with spaning of every worker on a single thread.
            nt.StartMultithreadedNative(numThreads, workerFunction);

            //nt.StartMultithreadedNativeV2(numThreads, workerFunction);

            //nt.StartWithTpl(numThreads, workerFunction);
            sw.Stop();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("{0} ms", sw.ElapsedMilliseconds);

            Console.ReadLine();
        }