Advertisement
Guest User

Untitled

a guest
May 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Cw1
  10. {
  11.     class Program
  12.     {
  13.         static void ThreadTask()
  14.         {
  15.             while (true)
  16.             {
  17.             }
  18.         }
  19.  
  20.         static void Main(string[] args)
  21.         {
  22.             var timer = new Stopwatch();
  23.  
  24.             timer.Start();
  25.             var t = new Thread(ThreadTask);
  26.             timer.Stop();
  27.  
  28.             Console.WriteLine("Tworzenie watku: {0}ms ({1} ticks)", timer.ElapsedMilliseconds, timer.ElapsedTicks);
  29.  
  30.             timer.Restart();
  31.             t.Abort();
  32.  
  33.             while (t.IsAlive)
  34.             {
  35.             }
  36.  
  37.             timer.Stop();
  38.  
  39.             Console.WriteLine("Usuwanie watku: {0}ms ({1} ticks)", timer.ElapsedMilliseconds, timer.ElapsedTicks);
  40.  
  41.             Console.ReadLine();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement