12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Lab193
- {
- class Program
- {
- static void TaskAction()
- {
- Console.WriteLine($"TaskAction started. Task ID: {Task.CurrentId}");
- for (int i = 0; i < 5; i++)
- {
- Thread.Sleep(1000);
- Console.WriteLine($"Task ID: {Task.CurrentId}; Count: {i}");
- }
- }
- public static void Main(string[] args)
- {
- Console.WriteLine("Main thread start!");
- Task task1 = new Task(TaskAction);
- Task task2 = new Task(TaskAction);
- task1.Start();
- task2.Start();
- for (int i = 0; i < 25; i++)
- {
- Console.Write(".");
- Thread.Sleep(500);
- }
- Console.WriteLine("Main thread stop!");
- }
- }
- }
|