SHARE
TWEET

Untitled

a guest Dec 6th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Diagnostics;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5.  
  6. namespace Test
  7. {
  8.     class Program
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             var rand = new Random();
  13.             double d = rand.NextDouble();
  14.  
  15.             Stopwatch stopwatch = new Stopwatch();
  16.  
  17.             stopwatch.Start();
  18.  
  19.             //Parallel.For(0, 7, (int i) => { Thread.Sleep(1000); d *= (i + 1); });
  20.             for (int i = 0; i <= 7; i++)
  21.             {
  22.                 Thread.Sleep(1000); d *= (i + 1);
  23.             }
  24.  
  25.             stopwatch.Stop();
  26.  
  27.             Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
  28.         }
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top