using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Thread blah;
public Form1()
{
InitializeComponent();
blah = new Thread(new ThreadStart(updateCounter));
blah.IsBackground = true;
}
int counterVariable = 0;
public void startButton1_Click(object sender, EventArgs e)
{
blah.Start();
}
public void updateCounter()
{
do
{
counterVariable++;
this.Invoke(delegate()
{
counterLabel1.Text = counterVariable.ToString();
});
}
while (counterVariable < 500);
}
public void stopButton1_Click(object sender, EventArgs e)
{
blah.Suspend();
}
}
}