Threading in C#
In this article I will explain about Thread in C#.
Introduction
Threading is allow a program to perform concurrent operation at a time so you can work more than two operation at a time in a program. In a C# program has one thread by default. This thread executes in main method in a c# program.
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace multi
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
Thread th = new Thread(WriteY);
th.Start();
for (int i = 0; i <= 10; i++)
{
Console.Write("\tHello");
}
Console.ReadKey();
}
private static void WriteY()
{
Console.ForegroundColor = ConsoleColor.Yellow;
for (int i = 0; i <= 9; i++)
{
Console.WriteLine("\n Hi");
}
}
}
}
Output