Program.cs 902 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace Lab193
  5. {
  6. class Program
  7. {
  8. static void TaskAction()
  9. {
  10. Console.WriteLine($"TaskAction started. Task ID: {Task.CurrentId}");
  11. for (int i = 0; i < 5; i++)
  12. {
  13. Thread.Sleep(1000);
  14. Console.WriteLine($"Task ID: {Task.CurrentId}; Count: {i}");
  15. }
  16. }
  17. public static void Main(string[] args)
  18. {
  19. Console.WriteLine("Main thread start!");
  20. Task task1 = new Task(TaskAction);
  21. Task task2 = new Task(TaskAction);
  22. task1.Start();
  23. task2.Start();
  24. for (int i = 0; i < 25; i++)
  25. {
  26. Console.Write(".");
  27. Thread.Sleep(500);
  28. }
  29. Console.WriteLine("Main thread stop!");
  30. }
  31. }
  32. }