Advertisement
Guest User

Untitled

a guest
May 6th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4.  
  5. namespace ConsoleApplication2
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. wyswietlCzas();
  12. Console.ReadLine();
  13. }
  14. static async void wyswietlCzas() //pobranie w osobnym wątku co 5 sek.
  15. {
  16.  
  17. await Task.Factory.StartNew(() =>
  18. {
  19. while (true)
  20. {
  21. int threadID = (int)AppDomain.GetCurrentThreadId();
  22. Thread.Sleep(5000);
  23. Console.WriteLine(DateTime.Now + Convert.ToString(threadID));
  24. }
  25. });
  26.  
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement