Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement