Threading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shimajavar
    New Member
    • Oct 2007
    • 17

    Threading

    Hi

    I have 2 buttons and for each one I have a thread.By clicking on button 1, thread1 (t1) starts.I have a while loop with this condition:

    while(t1.Thread State==ThreadSt ate.Running)

    which should be executed untill i put the thread into sleep, but actually after 20-30 times it stopps automatically!! !

    Can u guess why?
    Thank u in advanced


    public Program()
    {
    this.Size=new Size(800, 800);
    b1 = new Button();
    b1.Text = "Start";
    b1.Location = new Point(20, 200);
    b1.Click+=new EventHandler(b1 _Click);
    this.Controls.A dd(b1);
    t1 = new Thread(new ThreadStart(wri te));
    b2 = new Button();
    b2.Text = "Pause";
    b2.Location = new Point(120, 200);
    //b2.Click+=new EventHandler(b2 _Click);
    t2 = new Thread(new ThreadStart(wri te2));
    this.Controls.A dd(b2);

    }

    public void b1_Click(object sender, EventArgs e)
    {
    if (sender == b1)
    {
    Console.WriteLi ne(t1.ThreadSta te);
    if (t1.ThreadState == ThreadState.Uns tarted)
    {

    t1.Start();
    while (t1.ThreadState == ThreadState.Run ning)
    write();
    }
    }
    }
    public static void write()
    {

    Console.WriteLi ne("t1 is executing");
    }
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Please stop posting roughly the same question:



    Comment

    • shimajavar
      New Member
      • Oct 2007
      • 17

      #3
      it is not the same as last one!!!! i have asked about threadssss, have u read the question???

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Yes and everytime it's a TINY bit different but still comes down to the same question you asked before about growing a line and your related troubles in creating buttons to start and stop the process of doing it.
        I still consider it flooding the forums.

        Comment

        Working...