Hi
You can use very well Dylan's solution. That should work
Alternatively (However not recommended for a UI thred)......
Use the Threading timer as shown in the example below...it won't make your form unresponsive, because the timer will be in a different thread.
public partial class Form1 : Form
{
private static int Count = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
System.Threading.Timer timer = new System.Threading.Timer(new System.Threading.TimerCallback(MyIntervalFunction));
timer.Change(0, 2000);
}
private void MyIntervalFunction(object obj){
Count++;
if (label1.InvokeRequired == true)
{
this.Invoke((MethodInvoker)delegate
{
label1.Text = Count.ToString();
});
}
else
{
label1.Text = Count.ToString();
}
}
}
The count will be added to the label, still your form will be responsive.This is an example and you can use the MyIntervalFunction for your requirement