What is Task in c#

.Net framework provides System.Threading.Tasks.Task class to let you create threads and run them asynchronously.

using System;
using System.Threading.Tasks;

namespace TaskExample
{
public static class TaskProgram
{
    public static void Main()
        {
            Task t = Task.Run(() =>
            {
            for (int x = 0; x < 50; x++)
            {
            Console.Write(“Hi “);
            }
            });
            t.Wait();
        }
  }

}

Leave a comment