0% found this document useful (0 votes)
22 views

FRM Track Thread

This document defines a Windows form application that creates and manages four separate threads with different priorities. It defines two thread methods, assigns each one to a ThreadStart delegate, and creates Thread objects for each. It sets the name and priority of each thread, starts all four threads, and waits for them to finish using Join before ending the application.

Uploaded by

Unknown
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

FRM Track Thread

This document defines a Windows form application that creates and manages four separate threads with different priorities. It defines two thread methods, assigns each one to a ThreadStart delegate, and creates Thread objects for each. It sets the name and priority of each thread, starts all four threads, and waits for them to finish using Join before ending the application.

Uploaded by

Unknown
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

sing System;

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 LabExam
{
public partial class frmTrackThread : Form
{
public frmTrackThread()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Console.WriteLine("-Thread Start-");
lblThread.Text = "-Thread Start-";

ThreadStart thread1 = new ThreadStart(MyThreadClass.Thread1);


ThreadStart thread2 = new ThreadStart(MyThreadClass.Thread2);

Thread threadA = new Thread(thread1);


Thread threadB = new Thread(thread1);
Thread threadC = new Thread(thread2);
Thread threadD = new Thread(thread2);

threadA.Name = "Thread A Process ";


threadB.Name = "Thread B Process ";
threadC.Name = "Thread C Process ";
threadD.Name = "Thread D Process ";

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-";
}
}
}

You might also like