I am new in C#. I have two button and two label. What I want is that, When I click button1 it start counting and shows in label1. When I press button2 it resume counting under button1 and start counting under button2 and shows in label2. Here is my code
bool testt = true;
int i = 0;
int j = 0;
private void button1_Click(object sender, EventArgs e)
{
    while (testt)
    {
        label1.Text = i.ToString();
        i++;
        System.Threading.Thread.Sleep(50);
        if (i > 5000)
        {
            i = 0;
        }
    }
}
private void button2_Click(object sender, EventArgs e)
{
    testt = false;
    while (!testt)
    {
        label2.Text = j.ToString();
        j++;
        System.Threading.Thread.Sleep(50);
        if (j > 5000)
        {
            i = 0;
        }
    }
}
Here the problem is when I click one button, it does not allow me to click another button. I used a global variable to detect which button was pressed. But its not working. How can I make this work?
 
     
     
    