Event Driven
Event Driven
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace frmTrackThread
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
ThreadA.Priority = ThreadPriority.Highest;
ThreadB.Priority = ThreadPriority.Normal;
ThreadC.Priority = ThreadPriority.AboveNormal;
ThreadD.Priority = ThreadPriority.BelowNormal;
ThreadA.Start();
ThreadB.Start();
ThreadC.Start();
ThreadD.Start();
ThreadA.Join();
ThreadB.Join();
ThreadC.Join();
ThreadD.Join();
Console.WriteLine("-End of Thread-");
lblThread.Text = "-End of Thread-";
}
class MyThreadClass
{
public static void Thread1()
{
for (int i = 0; i <= 2; i++)
{
Thread thread = Thread.CurrentThread;
Console.WriteLine("Name of thread: " + thread.Name + " = " +
i);
Thread.Sleep(450);
}
}
public static void Thread2()
{
for (int i = 0; i <= 6; i++)
{
Thread thread = Thread.CurrentThread;
Console.WriteLine("Name of thread: " + thread.Name + " = " +
i);
Thread.Sleep(1500);
}
}
}
}