Exemplo n.º 1
0
 public void ChamadaParalela()
 {
     System.Console.WriteLine("\n chamado de forma paralela");
     Stopwatch sw2 = new Stopwatch();
     sw2.Start();
     Parallel.For(1, 50000, (i) => Infecta.Coronga(i));
     sw2.Stop();
     var tempo1 = sw2.ElapsedMilliseconds;
     Console.WriteLine($"Executando Coronga em paralelo em: {tempo1} ms ");
     Console.WriteLine();
 }
Exemplo n.º 2
0
        private void ChamadaSequencial1()
        {
            Console.WriteLine("Chamda de metodo sequencial");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Infecta.Coronga();
            Infecta.HIVA();
            sw.Stop();
            var tempo = sw.ElapsedMilliseconds / 1000;

            Console.WriteLine($"Executando tramissões com sucesso em: {tempo} s");
        }
Exemplo n.º 3
0
 public void ChamdaSequencial()
 {
     Stopwatch sw2 = new Stopwatch();
     sw2.Start();
     System.Console.WriteLine("\n chamado de forma sequencial" );
     for (int i = 1; i < 50000; i++)
     {
         Infecta.Coronga(i);
     }
     sw2.Stop();
     var tempo1 = sw2.ElapsedMilliseconds;
     Console.WriteLine($"************************************************Executando coronga em  Sequencial em: {tempo1} ms ");
     Console.WriteLine();
 }
Exemplo n.º 4
0
        public void ChamadaParalela()
        {
            Console.WriteLine("Chamda de metodo paralelo");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            Parallel.Invoke(
                () => Infecta.Coronga(),
                () => Infecta.HIVA()
                );
            sw.Stop();
            var tempo = sw.ElapsedMilliseconds / 1000;

            Console.WriteLine($"Executando tramissões em paralelo com sucesso em: {tempo} s");
        }