khalid sabtan

khalid sabtan

  • NA
  • 8
  • 560

could not restart thread

Aug 30 2021 10:00 AM

Hello
i have two thread they works in parallel.in formload i wrote
            t1 = new Thread(new ThreadStart(Print1));
            t2 = new Thread(new ThreadStart(Print2));
            t1.Name = "Primary";
            t2.Name = "Secondary";
i start the two threads from buttonClick.
        private void Print1Print2ThreadClick(object sender, EventArgs e)
        {
            label2.Text = "To Run 2 Threads Parrelly";

            if (t1.IsAlive == false) t1.Start();
            if (t2.IsAlive == false) t2.Start();  
            //
            //if (t1.IsAlive == false) t1.Abort();
            //if (t2.IsAlive == false) t1.Abort();
        }
they works fine but i could not restart the thread again without closing the program
i want to click that button again to restart the thread again and again
thanks