using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace ch14_2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PriorityTest priorityTest = new PriorityTest();
            ThreadStart startDelegate =
                new ThreadStart(priorityTest.ThreadMethod);

            Thread threadOne = new Thread(startDelegate);
            threadOne.Name = "ThreadOne";
            Thread threadTwo = new Thread(startDelegate);
            threadTwo.Name = "ThreadTwo";
            threadTwo.Priority = ThreadPriority.Highest;
            threadOne.Start();
            threadTwo.Start();
            // Allow counting for some time.
            Thread.Sleep(10);
            priorityTest.LoopSwitch = false;
           label1.Text = Sharing.output;
        }
    }
}
