C#.Rihter.TaskStatus

        static void Main(string[] args)
        {
            Task<int> t = new Task<int>(() =>
            {
                Console.WriteLine("smth in thread");
                return 123;
            });
            Console.WriteLine(t.Status);
            t.Start();
            Console.WriteLine(t.Status);

            Thread.Sleep(3000);
            Console.WriteLine(t.Status);
        }

output is

Created
WaitingToRun
smth in thread
RanToCompletion
This entry was posted in Без рубрики. Bookmark the permalink.